kmail
transportmanager.cpp
Go to the documentation of this file.00001 /* 00002 transportmanager.cpp 00003 00004 KMail, the KDE mail client. 00005 Copyright (c) 2002 Ingo Kloecker <kloecker@kde.org> 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License, 00009 version 2.0, as published by the Free Software Foundation. 00010 You should have received a copy of the GNU General Public License 00011 along with this program; if not, write to the Free Software Foundation, 00012 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US 00013 */ 00014 00015 #ifdef HAVE_CONFIG_H 00016 #include <config.h> 00017 #endif 00018 00019 #include "transportmanager.h" 00020 00021 #include "kmtransport.h" 00022 #include "kmkernel.h" 00023 #include <kapplication.h> 00024 #include <kconfig.h> 00025 00026 namespace KMail { 00027 00028 QStringList TransportManager::transportNames() 00029 { 00030 KConfigGroup general( KMKernel::config(), "General"); 00031 00032 int numTransports = general.readNumEntry("transports", 0); 00033 00034 QStringList transportNames; 00035 for ( int i = 1 ; i <= numTransports ; i++ ) { 00036 KMTransportInfo ti; 00037 ti.readConfig(i); 00038 transportNames << ti.name; 00039 } 00040 00041 return transportNames; 00042 } 00043 00044 // more or less copied from AccountManager 00045 uint TransportManager::createId() 00046 { 00047 QValueList<unsigned int> usedIds; 00048 00049 KConfigGroup general( KMKernel::config(), "General"); 00050 int numTransports = general.readNumEntry( "transports", 0 ); 00051 00052 for ( int i = 1 ; i <= numTransports ; i++ ) { 00053 KMTransportInfo ti; 00054 ti.readConfig( i ); 00055 usedIds << ti.id(); 00056 } 00057 00058 usedIds << 0; // 0 is default for unknown 00059 int newId; 00060 do 00061 { 00062 newId = kapp->random(); 00063 } while ( usedIds.find(newId) != usedIds.end() ); 00064 00065 return newId; 00066 } 00067 00068 } // namespace KMail