kpilot Library API Documentation

abbrowser-factory.cc

00001 /* abbrowser-factory.cc                      KPilot
00002 **
00003 ** Copyright (C) 2001 by Dan Pilone
00004 ** Copyright (C) 2002-2003 Reinhold Kainhofer
00005 **
00006 ** This file defines the factory for the abbrowser-conduit plugin.
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 #include "options.h"
00031 #include "abbrowser-factory.moc"
00032 
00033 #include <kinstance.h>
00034 #include <kaboutdata.h>
00035 
00036 #include "abbrowser-conduit.h"
00037 #include "abbrowser-setup.h"
00038 
00039 
00040 extern "C"
00041 {
00042 
00043 void *init_conduit_address()
00044 {
00045     return new AbbrowserConduitFactory;
00046 }
00047 
00048 }
00049 
00050 
00051 // A number of static variables; except for fAbout, they're
00052 // all KConfig group or entry keys.
00053 //
00054 //
00055 KAboutData *AbbrowserConduitFactory::fAbout = 0L;
00056 const char *AbbrowserConduitFactory::fGroup = "Abbrowser-conduit";
00057 
00058 const char *AbbrowserConduitFactory::fAbookType = "Addressbook type";
00059 const char *AbbrowserConduitFactory::fAbookFile = "FileName";
00060 const char *AbbrowserConduitFactory::fSyncMode = "SyncMode";
00061 const char *AbbrowserConduitFactory::fArchive = "ArchiveDeleted";
00062 const char *AbbrowserConduitFactory::fResolution = "ConflictResolve";
00063 const char *AbbrowserConduitFactory::fSmartMerge = "SmartMerge";
00064 const char *AbbrowserConduitFactory::fFirstSync = "FirstSync";
00065 const char *AbbrowserConduitFactory::fOtherField = "PilotOther";
00066 const char *AbbrowserConduitFactory::fStreetType = "PilotStreet";
00067 const char *AbbrowserConduitFactory::fFaxType = "PilotFax";
00068 const char *AbbrowserConduitFactory::fCustom = "Custom %1";
00069 const char *AbbrowserConduitFactory::fCustomFmt = "CustomDateFormat";
00070 
00071 
00072 
00073 AbbrowserConduitFactory::AbbrowserConduitFactory(QObject *p, const char *n) :
00074     KLibFactory(p,n)
00075 {
00076     FUNCTIONSETUP;
00077 
00078     fInstance = new KInstance("abbrowserconduit");
00079     fAbout = new KAboutData("abbrowserconduit",
00080         I18N_NOOP("Abbrowser Conduit for KPilot"),
00081         KPILOT_VERSION,
00082         I18N_NOOP("Configures the Abbrowser Conduit for KPilot"),
00083         KAboutData::License_GPL,
00084         "(C) 2001, Dan Pilone\n(C) 2002-2003, Reinhold Kainhofer");
00085     fAbout->addAuthor("Greg Stern",
00086         I18N_NOOP("Primary Author"));
00087     fAbout->addAuthor("Adriaan de Groot",
00088         I18N_NOOP("Maintainer"),
00089         "groot@kde.org",
00090         "http://www.cs.kun.nl/~adridg/kpilot");
00091     fAbout->addAuthor("Reinhold Kainhofer", I18N_NOOP("Maintainer"),
00092         "reinhold@kainhofer.com", "http://reinhold.kainhofer.com");
00093     fAbout->addCredit("David Bishop", I18N_NOOP("UI"));
00094 
00095 
00096 /*
00097 // This is just testing code for the custom fields sync. Does not yet work.
00098     char format[]="%d.%m.%y";
00099     QDateTime bdate, backdate;
00100     time_t btime, backt;
00101     struct tm*btmtime, backtm;
00102     char whatever[500];
00103     size_t len;
00104     QString strdate;
00105     char*end;
00106 
00107     bdate=QDateTime::currentDateTime();
00108     if (!bdate.isValid())  DEBUGCONDUIT<<"Not valid "<< endl;
00109 
00110     DEBUGCONDUIT<<"Birthdate="<<bdate.toString()<<endl;
00111 
00112     btime=bdate.toTime_t();
00113     btmtime=localtime(&btime);
00114     len=strftime(&whatever[0], 500, format, btmtime);
00115     strdate=&whatever[0];
00116     DEBUGCONDUIT<<"Birthdate="<<strdate<<endl;
00117 
00118 //  end=strptime(strdate.latin1(), format, &backtm);
00119 //  end=strptime("01.04.03 11:22:33", "%d.%m.%y %H:%M:%S", &backtm);
00120 DEBUGCONDUIT<<"latin1: "<<strdate.latin1()<<endl;
00121     end=strptime(strdate.latin1(), "%d.%m.%y", &backtm);
00122     DEBUGCONDUIT<< (int)end<<endl;
00123 
00124 //if (!end) {
00125     backt=mktime(&backtm);
00126     backdate.setTime_t(backt);
00127 //} else  DEBUGCONDUIT<<"Conversion failed"<<endl;
00128 
00129     DEBUGCONDUIT<<"Result of Back-conversion: "<<backdate.date().toString()<<endl;
00130 
00131 
00132 
00133 DEBUGCONDUIT<<"------------------------------------------"<<endl;
00134 
00135 
00136 
00137     bdate=QDateTime::currentDateTime();
00138     if (!bdate.isValid())  DEBUGCONDUIT<<"Not valid "<< endl;
00139 
00140     DEBUGCONDUIT<<"Birthdate="<<bdate.toString()<<endl;
00141 
00142     btime=bdate.toTime_t();
00143     btmtime=localtime(&btime);
00144     len=strftime(&whatever[0], 500, format, btmtime);
00145     strdate=&whatever[0];
00146     DEBUGCONDUIT<<"Birthdate="<<strdate<<endl;
00147 
00148 //  end=strptime(strdate.latin1(), format, &backtm);
00149     end=strptime("01.04.03 11:22:33", "%d.%m.%y %H:%M:%S", &backtm);
00150     DEBUGCONDUIT<< (int)end<<endl;
00151 
00152 //if (!end) {
00153     backt=mktime(&backtm);
00154     backdate.setTime_t(backt);
00155 //} else  DEBUGCONDUIT<<"Conversion failed"<<endl;
00156 
00157     DEBUGCONDUIT<<"Result of Back-conversion: "<<backdate.date().toString()<<endl;
00158 
00159 */
00160 
00161 
00162 }
00163 
00164 AbbrowserConduitFactory::~AbbrowserConduitFactory()
00165 {
00166     FUNCTIONSETUP;
00167 
00168     KPILOT_DELETE(fInstance);
00169     KPILOT_DELETE(fAbout);
00170 }
00171 
00172 /* virtual */ QObject *AbbrowserConduitFactory::createObject( QObject *p,
00173     const char *n,
00174     const char *c,
00175     const QStringList &a)
00176 {
00177     FUNCTIONSETUP;
00178 
00179 #ifdef DEBUG
00180     DEBUGCONDUIT << fname
00181         << ": Creating object of class "
00182         << c
00183         << endl;
00184 #endif
00185 
00186     if (qstrcmp(c,"ConduitConfigBase")==0)
00187     {
00188         QWidget *w = dynamic_cast<QWidget *>(p);
00189 
00190         if (w)
00191         {
00192             return new AbbrowserWidgetSetup(w,n);
00193         }
00194         else
00195         {
00196             kdError() << k_funcinfo
00197                 << ": Couldn't cast parent to widget."
00198                 << endl;
00199             return 0L;
00200         }
00201     }
00202     if (qstrcmp(c,"ConduitConfig")==0)
00203     {
00204         QWidget *w = dynamic_cast<QWidget *>(p);
00205 
00206         if (w)
00207         {
00208             return new ConduitConfigImplementation(w,n,a,
00209                 AbbrowserWidgetSetup::create);
00210         }
00211         else
00212         {
00213             kdError() << k_funcinfo
00214                 << ": Couldn't cast parent to widget."
00215                 << endl;
00216             return 0L;
00217         }
00218     }
00219 
00220     if (qstrcmp(c,"SyncAction")==0)
00221     {
00222         KPilotDeviceLink *d = dynamic_cast<KPilotDeviceLink *>(p);
00223 
00224         if (d)
00225         {
00226             return new AbbrowserConduit(d,n,a);
00227         }
00228         else
00229         {
00230             kdError() << k_funcinfo
00231                 << ": Couldn't cast parent to KPilotDeviceLink"
00232                 << endl;
00233             return 0L;
00234         }
00235     }
00236 
00237     return 0L;
00238 }
00239 
00240 
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:46 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003