console/kabcclient
kabcclient.h
Go to the documentation of this file.00001 // 00002 // Copyright (C) 2005 - 2006 Kevin Krammer <kevin.krammer@gmx.at> 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 // 00018 00019 #ifndef KABCCLIENT_H 00020 #define KABCCLIENT_H 00021 00022 // standard includes 00023 #include <istream> 00024 00025 // Qt includes 00026 #include <QtCore/QObject> 00027 00028 // forward declarations 00029 class FormatFactory; 00030 class InputFormat; 00031 class OutputFormat; 00032 class QTextCodec; 00033 00034 namespace KABC 00035 { 00036 class AddressBook; 00037 class Addressee; 00038 class Picture; 00039 } 00040 00050 class KABCClient: public QObject 00051 { 00052 Q_OBJECT 00053 00054 public: 00058 enum Operation 00059 { 00065 List = 0, 00066 00078 Add, 00079 00095 Remove, 00096 00112 Merge, 00113 00124 Search 00125 }; 00126 00133 KABCClient(Operation operation, FormatFactory* factory); 00134 00138 virtual ~KABCClient(); 00139 00157 bool setInputFormat(const QByteArray& name); 00158 00173 bool setOutputFormat(const QByteArray& name); 00174 00188 bool setInputOptions(const QByteArray& options); 00189 00203 bool setOutputOptions(const QByteArray& options); 00204 00217 bool setInputCodec(const QByteArray& name); 00218 00231 bool setOutputCodec(const QByteArray& name); 00232 00241 void setInputStream(std::istream* stream); 00242 00251 bool initOperation(); 00252 00260 inline void setMatchCaseSensitivity(Qt::CaseSensitivity sensitivity) 00261 { 00262 m_matchCaseSensitivity = sensitivity; 00263 } 00264 00277 inline void setAllowSaving(bool on) { m_allowSaving = on; } 00278 00279 private: 00280 Operation m_operation; 00281 00282 FormatFactory* m_formatFactory; 00283 00284 InputFormat* m_inputFormat; 00285 OutputFormat* m_outputFormat; 00286 00287 QTextCodec* m_inputCodec; 00288 QTextCodec* m_outputCodec; 00289 00290 KABC::AddressBook* m_addressBook; 00291 00292 std::istream* m_inputStream; 00293 00294 Qt::CaseSensitivity m_matchCaseSensitivity; 00295 bool m_allowSaving; 00296 00297 private: 00298 int performAdd(); 00299 int performRemove(); 00300 int performMerge(); 00301 int performList(); 00302 int performSearch(); 00303 00304 void mergeAddressees(KABC::Addressee& master, const KABC::Addressee& slave); 00305 void mergePictures(KABC::Picture& master, const KABC::Picture slave); 00306 00307 QTextCodec* codecForName(const QByteArray& name); 00308 00309 private slots: 00310 void slotAddressBookLoaded(); 00311 }; 00312 00313 #endif 00314 00315 // End of file
KDE 4.2 API Reference