summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp2
-rw-r--r--kabc/plugins/file/resourcefile.cpp28
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp2
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp2
-rw-r--r--kabc/resource.cpp5
-rw-r--r--kabc/resource.h2
-rw-r--r--kabc/stdaddressbook.cpp6
-rw-r--r--kabc/syncprefwidget.cpp581
-rw-r--r--kabc/syncprefwidget.h138
12 files changed, 350 insertions, 422 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 20310a0..c61b387 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -226,25 +226,25 @@ AddressBook::AddressBook( const QString &config )
226 226
227AddressBook::AddressBook( const QString &config, const QString &family ) 227AddressBook::AddressBook( const QString &config, const QString &family )
228{ 228{
229 init(config, family); 229 init(config, family);
230 230
231} 231}
232 232
233// the default family is "contact" 233// the default family is "contact"
234void AddressBook::init(const QString &config, const QString &family ) 234void AddressBook::init(const QString &config, const QString &family )
235{ 235{
236 d = new AddressBookData; 236 d = new AddressBookData;
237 if (config != 0) { 237 if (config != 0) {
238 d->mConfig = new KConfig( config ); 238 d->mConfig = new KConfig( locateLocal("config", config) );
239// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 239// qDebug("AddressBook::init 1 config=%s",config.latin1() );
240 } 240 }
241 else { 241 else {
242 d->mConfig = 0; 242 d->mConfig = 0;
243// qDebug("AddressBook::init 1 config=0"); 243// qDebug("AddressBook::init 1 config=0");
244 } 244 }
245 245
246//US d->mErrorHandler = 0; 246//US d->mErrorHandler = 0;
247 d->mManager = new KRES::Manager<Resource>( family, false ); 247 d->mManager = new KRES::Manager<Resource>( family, false );
248 d->mManager->readConfig( d->mConfig ); 248 d->mManager->readConfig( d->mConfig );
249} 249}
250 250
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index 29f1e3a..eccd482 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -62,25 +62,25 @@ $Id$
62using namespace KABC; 62using namespace KABC;
63 63
64extern "C" 64extern "C"
65#ifdef _WIN32_ 65#ifdef _WIN32_
66__declspec(dllexport) 66__declspec(dllexport)
67#else 67#else
68{ 68{
69#endif 69#endif
70 70
71//US void *init_kabc_dir() 71//US void *init_kabc_dir()
72 void *init_microkabc_dir() 72 void *init_microkabc_dir()
73 { 73 {
74 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidget>(); 74 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidgetContainer>();
75 } 75 }
76#ifndef _WIN32_ 76#ifndef _WIN32_
77} 77}
78#endif 78#endif
79 79
80ResourceDir::ResourceDir( const KConfig *config, bool syncable ) 80ResourceDir::ResourceDir( const KConfig *config, bool syncable )
81 : Resource( config, syncable ) 81 : Resource( config, syncable )
82{ 82{
83 QString path; 83 QString path;
84 84
85 KConfig *cfg = (KConfig *)config; 85 KConfig *cfg = (KConfig *)config;
86 if ( cfg ) { 86 if ( cfg ) {
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index d98efc8..da2e4d7 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -57,44 +57,47 @@ $Id$
57using namespace KABC; 57using namespace KABC;
58 58
59extern "C" 59extern "C"
60#ifdef _WIN32_ 60#ifdef _WIN32_
61__declspec(dllexport) 61__declspec(dllexport)
62#else 62#else
63{ 63{
64#endif 64#endif
65 65
66//US void *init_kabc_file() 66//US void *init_kabc_file()
67 void *init_microkabc_file() 67 void *init_microkabc_file()
68 { 68 {
69 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidget>(); 69 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>();
70 } 70 }
71#ifndef _WIN32_ 71#ifndef _WIN32_
72} 72}
73#endif 73#endif
74 74
75ResourceFile::ResourceFile( const KConfig *config, bool syncable ) 75ResourceFile::ResourceFile( const KConfig *config, bool syncable )
76 : Resource( config, syncable ) , mFormat( 0 ) 76 : Resource( config, syncable ) , mFormat( 0 )
77{ 77{
78 QString fileName, formatName; 78 QString fileName, formatName, default_fileName;
79
80 if (syncable == true)
81 default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf";
82 else
83 default_fileName = StdAddressBook::fileName();
79 84
80 KConfig *cfg = (KConfig *)config; 85 KConfig *cfg = (KConfig *)config;
81 if ( cfg ) { 86 if ( cfg ) {
82 fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); 87 fileName = cfg->readEntry( "FileName", default_fileName );
83 formatName = cfg->readEntry( "FileFormat", "vcard" ); 88 formatName = cfg->readEntry( "FileFormat", "vcard" );
84// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
85 } else { 89 } else {
86 fileName = StdAddressBook::fileName(); 90 fileName = default_fileName;
87 formatName = "vcard"; 91 formatName = "vcard";
88// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
89 } 92 }
90 93
91 init( fileName, formatName ); 94 init( fileName, formatName );
92} 95}
93 96
94ResourceFile::ResourceFile( const QString &fileName, bool syncable , 97ResourceFile::ResourceFile( const QString &fileName, bool syncable ,
95 const QString &formatName ) 98 const QString &formatName )
96 : Resource( 0, syncable ) 99 : Resource( 0, syncable )
97{ 100{
98// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 101// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
99 init( fileName, formatName ); 102 init( fileName, formatName );
100} 103}
@@ -102,37 +105,24 @@ ResourceFile::ResourceFile( const QString &fileName, bool syncable ,
102void ResourceFile::init( const QString &fileName, const QString &formatName ) 105void ResourceFile::init( const QString &fileName, const QString &formatName )
103{ 106{
104 mFormatName = formatName; 107 mFormatName = formatName;
105 108
106 FormatFactory *factory = FormatFactory::self(); 109 FormatFactory *factory = FormatFactory::self();
107 mFormat = factory->format( mFormatName ); 110 mFormat = factory->format( mFormatName );
108 111
109 if ( !mFormat ) { 112 if ( !mFormat ) {
110 mFormatName = "vcard"; 113 mFormatName = "vcard";
111 mFormat = factory->format( mFormatName ); 114 mFormat = factory->format( mFormatName );
112 } 115 }
113 116
114/*US
115//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1());
116 if (mFormatName == "vcard") {
117 mFormat = new VCardFormatPlugin2();
118// qDebug("ResourceFile::init format VCardFormatPlugin2");
119 }
120 else if (mFormatName == "binary") {
121 mFormat = new BinaryFormat();
122// qDebug("ResourceFile::init format BinaryFormat");
123 }
124 else
125 qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1());
126*/
127 117
128 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 118 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
129 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 119 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
130 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 120 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
131 121
132 setFileName( fileName ); 122 setFileName( fileName );
133} 123}
134 124
135ResourceFile::~ResourceFile() 125ResourceFile::~ResourceFile()
136{ 126{
137 delete mFormat; 127 delete mFormat;
138 mFormat = 0; 128 mFormat = 0;
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
index 198e80a..17f115d 100644
--- a/kabc/plugins/ldap/resourceldap.cpp
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -36,25 +36,25 @@ $Id$
36 36
37#include "resourceldap.h" 37#include "resourceldap.h"
38#include "resourceldapconfig.h" 38#include "resourceldapconfig.h"
39#include "syncprefwidget.h" 39#include "syncprefwidget.h"
40 40
41using namespace KABC; 41using namespace KABC;
42 42
43extern "C" 43extern "C"
44{ 44{
45//US void *init_kabc_ldap() 45//US void *init_kabc_ldap()
46 void *init_microkabc_ldap() 46 void *init_microkabc_ldap()
47 { 47 {
48 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidget>(); 48 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidgetContainer>();
49 } 49 }
50} 50}
51 51
52void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); 52void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
53 53
54 54
55ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable ) 55ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable )
56 : Resource( config, syncable ), mPort( 389 ), mLdap( 0 ) 56 : Resource( config, syncable ), mPort( 389 ), mLdap( 0 )
57{ 57{
58 KConfig *cfg = (KConfig *)config; 58 KConfig *cfg = (KConfig *)config;
59 if ( cfg ) { 59 if ( cfg ) {
60 mUser = cfg->readEntry( "LdapUser" ); 60 mUser = cfg->readEntry( "LdapUser" );
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 9dfd473..4b811e9 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -52,25 +52,25 @@ $Id$
52#include "stdaddressbook.h" 52#include "stdaddressbook.h"
53#include "syncprefwidget.h" 53#include "syncprefwidget.h"
54 54
55#include "opieconverter.h" 55#include "opieconverter.h"
56 56
57#include "resourceopie.h" 57#include "resourceopie.h"
58 58
59using namespace KABC; 59using namespace KABC;
60extern "C" 60extern "C"
61{ 61{
62 void *init_microkabc_opie() 62 void *init_microkabc_opie()
63 { 63 {
64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidget>(); 64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidgetContainer>();
65 } 65 }
66} 66}
67 67
68ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) 68ResourceOpie::ResourceOpie( const KConfig *config, bool syncable )
69 : Resource( config, syncable ), mAccess(0), mConverter (0) 69 : Resource( config, syncable ), mAccess(0), mConverter (0)
70{ 70{
71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
72 72
73 KConfig *cfg = (KConfig *)config; 73 KConfig *cfg = (KConfig *)config;
74 if ( cfg ) { 74 if ( cfg ) {
75 fileName = cfg->readEntry( "FileName", fileName ); 75 fileName = cfg->readEntry( "FileName", fileName );
76 76
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 5565580..93a4d33 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -49,25 +49,25 @@ $Id$
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncprefwidget.h" 52#include "syncprefwidget.h"
53 53
54#include "resourceqtopia.h" 54#include "resourceqtopia.h"
55 55
56using namespace KABC; 56using namespace KABC;
57extern "C" 57extern "C"
58{ 58{
59 void *init_microkabc_qtopia() 59 void *init_microkabc_qtopia()
60 { 60 {
61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidget>(); 61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>();
62 } 62 }
63} 63}
64 64
65ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) 65ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
66 : Resource( config, syncable ), mConverter (0) 66 : Resource( config, syncable ), mConverter (0)
67{ 67{
68 // we can not choose the filename. Therefore use the default to display 68 // we can not choose the filename. Therefore use the default to display
69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
70 init( fileName ); 70 init( fileName );
71} 71}
72 72
73ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) 73ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 70c3718..b63df0c 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -51,25 +51,25 @@ $Id$
51 51
52#include "syncprefwidget.h" 52#include "syncprefwidget.h"
53 53
54#include "stdaddressbook.h" 54#include "stdaddressbook.h"
55 55
56#include "sharpdtmconverter.h" 56#include "sharpdtmconverter.h"
57 57
58using namespace KABC; 58using namespace KABC;
59extern "C" 59extern "C"
60{ 60{
61 void *init_microkabc_sharpdtm() 61 void *init_microkabc_sharpdtm()
62 { 62 {
63 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidget>(); 63 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>();
64 } 64 }
65} 65}
66 66
67ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) 67ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable )
68 : Resource( config, syncable ), mConverter (0) 68 : Resource( config, syncable ), mConverter (0)
69{ 69{
70 // we can not choose the filename. Therefore use the default to display 70 // we can not choose the filename. Therefore use the default to display
71 71
72 QString fileName = SlZDataBase::addressbookFileName(); 72 QString fileName = SlZDataBase::addressbookFileName();
73 init( fileName ); 73 init( fileName );
74} 74}
75 75
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 2f03927..d39fd6a 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -104,24 +104,29 @@ void Resource::removeAddressee( const Addressee& )
104} 104}
105 105
106void Resource::cleanUp() 106void Resource::cleanUp()
107{ 107{
108 // do nothing 108 // do nothing
109} 109}
110 110
111bool Resource::isSyncable() const 111bool Resource::isSyncable() const
112{ 112{
113 return (mSyncProfile != 0); 113 return (mSyncProfile != 0);
114} 114}
115 115
116KSyncProfile* Resource::getSyncProfile()
117{
118 return mSyncProfile;
119}
120
116 121
117QString Resource::fileName() const 122QString Resource::fileName() const
118{ 123{
119 return mFileName; 124 return mFileName;
120} 125}
121 126
122void Resource::setFileName( const QString &fileName ) 127void Resource::setFileName( const QString &fileName )
123{ 128{
124 mFileName = fileName; 129 mFileName = fileName;
125} 130}
126 131
127/** 132/**
diff --git a/kabc/resource.h b/kabc/resource.h
index 7d42f81..2024d2d 100644
--- a/kabc/resource.h
+++ b/kabc/resource.h
@@ -133,24 +133,26 @@ public:
133 * Set name of file to be used for saving. 133 * Set name of file to be used for saving.
134 */ 134 */
135 virtual void setFileName( const QString & ); 135 virtual void setFileName( const QString & );
136 136
137 /** 137 /**
138 * Return name of file used for loading and saving the address book. 138 * Return name of file used for loading and saving the address book.
139 */ 139 */
140 virtual QString fileName() const; 140 virtual QString fileName() const;
141 141
142 142
143 virtual bool isSyncable() const; 143 virtual bool isSyncable() const;
144 144
145 virtual KSyncProfile* getSyncProfile();
146
145 /** 147 /**
146 * Set the name of resource.You can override this method, 148 * Set the name of resource.You can override this method,
147 * but also remember to call Resource::setResourceName(). 149 * but also remember to call Resource::setResourceName().
148 */ 150 */
149 virtual void setResourceName( const QString &name ); 151 virtual void setResourceName( const QString &name );
150 152
151 153
152 154
153protected: 155protected:
154 Ticket *createTicket( Resource * ); 156 Ticket *createTicket( Resource * );
155 virtual void doClose(); 157 virtual void doClose();
156 158
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index 1e00cc6..760820e 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -103,34 +103,32 @@ StdAddressBook *StdAddressBook::self( bool onlyFastResources )
103 QString appdir =StdAddressBook::setTempAppDir(); 103 QString appdir =StdAddressBook::setTempAppDir();
104#ifdef KAB_EMBEDDED 104#ifdef KAB_EMBEDDED
105 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); 105 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
106#else //KAB_EMBEDDED 106#else //KAB_EMBEDDED
107 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); 107 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
108#endif //KAB_EMBEDDED 108#endif //KAB_EMBEDDED
109 KStandardDirs::setAppDir( appdir ); 109 KStandardDirs::setAppDir( appdir );
110 } 110 }
111 return mSelf; 111 return mSelf;
112} 112}
113 113
114StdAddressBook::StdAddressBook() 114StdAddressBook::StdAddressBook()
115//US : AddressBook( "kabcrc" ) 115 : AddressBook( "kabcrc" )
116 : AddressBook( locateLocal( "config", "kabcrc") )
117{ 116{
118 117
119 init( false ); 118 init( false );
120} 119}
121 120
122StdAddressBook::StdAddressBook( bool onlyFastResources ) 121StdAddressBook::StdAddressBook( bool onlyFastResources )
123//US : AddressBook( "kabcrc" ) 122 : AddressBook( "kabcrc" )
124 : AddressBook( locateLocal( "config", "kabcrc") )
125{ 123{
126 124
127 init( onlyFastResources ); 125 init( onlyFastResources );
128} 126}
129 127
130StdAddressBook::~StdAddressBook() 128StdAddressBook::~StdAddressBook()
131{ 129{
132 if ( mAutomaticSave ) 130 if ( mAutomaticSave )
133 save(); 131 save();
134} 132}
135 133
136void StdAddressBook::init( bool ) 134void StdAddressBook::init( bool )
diff --git a/kabc/syncprefwidget.cpp b/kabc/syncprefwidget.cpp
index 51a8040..a2bde72 100644
--- a/kabc/syncprefwidget.cpp
+++ b/kabc/syncprefwidget.cpp
@@ -16,316 +16,169 @@
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US
29#include <qlayout.h>
30#include <qlabel.h>
31#include <qgroupbox.h>
32#include <qbuttongroup.h>
33#include <qlineedit.h>
34#include <qfont.h>
35#include <qslider.h>
36#include <qfile.h>
37#include <qtextstream.h>
38#include <qcombobox.h>
39#include <qvbox.h>
40#include <qhbox.h>
41#include <qspinbox.h>
42#include <qdatetime.h>
43#include <qcheckbox.h>
44#include <qradiobutton.h>
45#include <qpushbutton.h>
46#include <qstrlist.h>
47#include <qapplication.h>
48
49#include <kcolorbutton.h>
50#include <kdebug.h>
51#include <klocale.h>
52#include <kglobal.h>
53#include <kfontdialog.h>
54#include <kmessagebox.h>
55#include <kcolordialog.h>
56#include <kiconloader.h>
57#include <kemailsettings.h>
58#include <kstandarddirs.h>
59#include <kfiledialog.h>
60#include <kmessagebox.h>
61
62#include <kurlrequester.h>
63#include <klineedit.h>
64#include <libkdepim/ksyncprofile.h>
65
66
67#include "koprefs.h"
68
69#include "kosyncprefsdialog.h"
70#include "koglobals.h"
71*/
72 28
73#include <qlayout.h> 29#include <qlayout.h>
74#include <qbuttongroup.h> 30#include <qbuttongroup.h>
75#include <qcheckbox.h> 31#include <qcheckbox.h>
76#include <qradiobutton.h> 32#include <qradiobutton.h>
77#include <qvbox.h> 33#include <qvbox.h>
78#include <qhbox.h> 34#include <qhbox.h>
79#include <qlabel.h> 35#include <qlabel.h>
80#include <qlineedit.h> 36#include <qlineedit.h>
81#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qscrollview.h>
39#include <qcombobox.h>
82 40
83 41
84#include <klocale.h> 42#include <klocale.h>
85#include <kdialog.h> 43#include <kdialog.h>
86 44
87 45#include "ksyncprofile.h"
46#include "resource.h"
88#include "syncprefwidget.h" 47#include "syncprefwidget.h"
89 48
90 49
91SyncPrefWidget::SyncPrefWidget(QWidget *parent) : 50SyncPrefWidget_Settings::SyncPrefWidget_Settings(QWidget *parent, const char *name) :
92 KRES::SyncWidget(parent) 51 KRES::SyncWidget(parent, name)
93{ 52{
94
95//US setCaption( i18n("Synchronization Preferences"));
96
97//US mSyncProfiles.setAutoDelete( true );
98 init(); 53 init();
99} 54}
100 55
101 56
102SyncPrefWidget::~SyncPrefWidget() 57SyncPrefWidget_Settings::~SyncPrefWidget_Settings()
103{ 58{
104} 59}
105 60
106//US #include <qlayout.h> 61void SyncPrefWidget_Settings::init()
107//US #include <qscrollview.h>
108void SyncPrefWidget::init()
109{ 62{
110 QLabel * lab;
111 QPushButton* button;
112
113/*US
114 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
115 QVBox * mainbox = new QVBox( this );
116 QScrollView* sv = new QScrollView( mainbox );
117 QHBoxLayout * lay = new QHBoxLayout( this );
118 lay->addWidget( mainbox );
119 QHBox * b_box = new QHBox( mainbox );
120*/
121/*US
122 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
123 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
124 button = new QPushButton( i18n("Cancel"), b_box );
125 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
126*/
127 //QBoxLayout * sl = new QVBoxLayout(this );
128 //sl->addWidget ( sv );
129/*US
130 sv->setResizePolicy ( QScrollView::AutoOneFit );
131 QFrame *topFrame = new QFrame ( sv );
132 sv->addChild( topFrame );
133 mSetupSyncAlgTab = topFrame;
134 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
135 topLayout->setSpacing(spacingHint());
136 topLayout->setMargin(marginHint());
137*/
138//US new code for the layout
139 QGridLayout *topLayout = new QGridLayout( this, 6,2 ); 63 QGridLayout *topLayout = new QGridLayout( this, 6,2 );
140 topLayout->setMargin( KDialog::marginHint() ); 64 topLayout->setMargin( KDialog::marginHint() );
141 topLayout->setSpacing( KDialog::spacingHint() ); 65 topLayout->setSpacing( KDialog::spacingHint() );
142 66
143 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
144 int iii = 0; 67 int iii = 0;
145 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
146 //++iii;
147
148/*US
149 mMyMachineName = new QLineEdit(topFrame);
150 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
151 topLayout->addWidget(lab ,iii,0);
152 topLayout->addWidget(mMyMachineName,iii,1);
153 ++iii;
154
155 QHBox* buttonbox = new QHBox( topFrame);
156 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
157 ++iii;
158 button = new QPushButton( i18n("New profile"), buttonbox );
159 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
160
161 button = new QPushButton( i18n("Clone profile"), buttonbox );
162 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
163
164 button = new QPushButton( i18n("Delete profile"), buttonbox );
165 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
166
167 mProfileBox = new QComboBox(topFrame);
168 mProfileBox->setEditable ( true );
169 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
170 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
171
172 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
173 topLayout->addWidget(lab ,iii,0);
174 topLayout->addWidget(mProfileBox, iii,1);
175 ++iii;
176*/
177 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), this ); 68 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), this );
178 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 69 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
179 ++iii; 70 ++iii;
180 71
181 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), this ); 72 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), this );
182 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 73 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
183 ++iii; 74 ++iii;
184 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), this);
185 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
186 ++iii;
187 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
188 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
189 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
190 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
191 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
192 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
193 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
194 75
195 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), this ); 76 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), this );
196 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 77 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
197 ++iii; 78 ++iii;
198 79
199 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), this ); 80 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), this );
200 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 81 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
201 ++iii; 82 ++iii;
202 83
203 mWriteBackFile = new QCheckBox( i18n("Write back file"), this ); 84 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), this );
204 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 85 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
205 ++iii; 86 ++iii;
206 87
207 mIsNotLocal = new QCheckBox( i18n("Remote file (w down/upload command)"), this ); 88}
208 topLayout->addMultiCellWidget(mIsNotLocal, iii,iii,0,1);
209 connect (mIsNotLocal, SIGNAL( checked(bool)), this, SLOT (kindChanged(bool) ) );
210/*US
211 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this);
212 gr = proGr;
213 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
214 ++iii;
215 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
216 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
217 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
218*/
219 89
220/*US 90void SyncPrefWidget_Settings::loadSettings( KRES::Resource *res )
221 localFileWidget = new QVBox( topFrame); 91{
222 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 92 KABC::Resource* resource = (KABC::Resource*)( res );
223 ++iii; 93 KSyncProfile* prof = resource->getSyncProfile();
224 QHBox* temphb = new QHBox( localFileWidget );
225 lab = new QLabel( i18n("Local file:"), temphb);
226 mRemoteFile = new QLineEdit(localFileWidget);
227 94
228 button = new QPushButton( i18n("Choose..."), temphb ); 95 if (prof == 0)
229 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 96 {
230*/ 97 qDebug("SyncPrefWidget_Settings::loadSettings: something is wrong, because resource does have no syncprofile" );
231 QHBox* temphb; 98 return;
99 }
232 100
233 remoteFileWidget = new QVBox( this); 101 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
234 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 102 mAskForPreferences->setChecked( prof->getAskForPreferences());
235 ++iii; 103 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
236 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 104 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
237 mRemotePrecommand = new QLineEdit(remoteFileWidget); 105 mWriteBackFile->setChecked( prof->getWriteBackFile());
106}
238 107
239 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 108void SyncPrefWidget_Settings::saveSettings( KRES::Resource *res )
240 mLocalTempFile = new QLineEdit(remoteFileWidget); 109{
110 KABC::Resource* resource = (KABC::Resource*)( res );
111 KSyncProfile* prof = resource->getSyncProfile();
241 112
113 if (prof == 0)
114 {
115 qDebug("SyncPrefWidget_Settings::saveSettings: something is wrong, because resource does have no syncprofile" );
116 return;
117 }
242 118
243 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 119 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
244 mRemotePostcommand = new QLineEdit(remoteFileWidget); 120 prof->setAskForPreferences( mAskForPreferences->isChecked());
121 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
122 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
123 prof->setWriteBackFile( mWriteBackFile->isChecked());
124}
245 125
246 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
247 temphb = new QHBox( remoteFileWidget );
248 button = new QPushButton( i18n("ssh/scp"), temphb );
249 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
250 button = new QPushButton( i18n("ftp"), temphb );
251 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
252 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
253 126
127/***********************************************************************
128 *
129 *
130 **********************************************************************/
254 131
255} 132SyncPrefWidget_Conflict::SyncPrefWidget_Conflict(QWidget *parent, const char *name) :
256/*US 133 KRES::SyncWidget(parent, name)
257void SyncPrefWidget::slotOK()
258{ 134{
259 if ( mMyMachineName->text() == "undefined" ) { 135 init();
260 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
261 return;
262 }
263 int i;
264 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
265 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
266 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
267 return;
268 }
269 }
270 usrWriteConfig();
271 QDialog::accept();
272} 136}
273void SyncPrefWidget::accept() 137
138
139SyncPrefWidget_Conflict::~SyncPrefWidget_Conflict()
274{ 140{
275 slotOK();
276} 141}
277void KOSyncPrefsDialog::chooseFile() 142
143void SyncPrefWidget_Conflict::init()
278{ 144{
279 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 145 QGridLayout *topLayout = new QGridLayout( this, 6,2 );
146 topLayout->setMargin( KDialog::marginHint() );
147 topLayout->setSpacing( KDialog::spacingHint() );
280 148
281 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 149 int iii = 0;
282 if ( fn == "" ) 150
283 return; 151 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("In case of conflicts"), this);
284 mRemoteFile->setText( fn ); 152 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
153 ++iii;
154 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
155 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
156 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
157 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
158 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
159 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
160 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
285} 161}
286 162
287void KOSyncPrefsDialog::textChanged( const QString & s ) 163void SyncPrefWidget_Conflict::loadSettings( KRES::Resource *res )
288{ 164{
289 if ( mProfileBox->count() == 0 ) 165 KABC::Resource* resource = (KABC::Resource*)( res );
290 return; 166 KSyncProfile* prof = resource->getSyncProfile();
291 if ( currentSelection < 3 ) { 167
292 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 168 if (prof == 0)
293 mProfileBox->blockSignals( true ); 169 {
294 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 170 qDebug("SyncPrefWidget_Conflict::loadSettings: something is wrong, because resource does have no syncprofile" );
295 mProfileBox->blockSignals( false );
296 return; 171 return;
297 } 172 }
298 //qDebug("cur i %d ",mProfileBox-> currentItem () );
299 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
300 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
301 prof->setName( s );
302 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
303}
304void KOSyncPrefsDialog::profileChanged( int item )
305{
306 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
307 KSyncProfile* prof;
308 saveProfile();
309 currentSelection = item;
310 prof = mSyncProfiles.at(item) ;
311 mRemotePrecommand->setText(prof->getPreSyncCommand());
312 mRemotePostcommand->setText(prof->getPostSyncCommand());
313 mLocalTempFile->setText(prof->getLocalTempFile());
314 mRemoteFile->setText(prof->getRemoteFileName()) ;
315 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
316 mAskForPreferences->setChecked( prof->getAskForPreferences());
317 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
318 mWriteBackFile->setChecked( prof->getWriteBackFile());
319 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
320 173
321 switch ( prof->getSyncPrefs() ) { 174 switch ( prof->getSyncPrefs() ) {
322 case 0: 175 case 0:
323 loc->setChecked( true); 176 loc->setChecked( true);
324 break; 177 break;
325 case 1: 178 case 1:
326 rem->setChecked( true ); 179 rem->setChecked( true );
327 break; 180 break;
328 case 2: 181 case 2:
329 newest->setChecked( true); 182 newest->setChecked( true);
330 break; 183 break;
331 case 3: 184 case 3:
@@ -334,162 +187,224 @@ void KOSyncPrefsDialog::profileChanged( int item )
334 case 4: 187 case 4:
335 f_loc->setChecked( true); 188 f_loc->setChecked( true);
336 break; 189 break;
337 case 5: 190 case 5:
338 f_rem->setChecked( true); 191 f_rem->setChecked( true);
339 break; 192 break;
340 case 6: 193 case 6:
341 //both->setChecked( true); 194 //both->setChecked( true);
342 break; 195 break;
343 default: 196 default:
344 break; 197 break;
345 } 198 }
346 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
347 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
348 proGr->setEnabled( item > 2 );
349 if ( item < 3 ) {
350 localFileWidget->setEnabled(false);
351 remoteFileWidget->setEnabled(false);
352
353 } else
354 kindChanged( prof->getIsLocalFileSync() );
355} 199}
356 200
357void KOSyncPrefsDialog::fillSSH() 201void SyncPrefWidget_Conflict::saveSettings( KRES::Resource *res )
358{ 202{
359 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 203 KABC::Resource* resource = (KABC::Resource*)( res );
360 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 204 KSyncProfile* prof = resource->getSyncProfile();
361 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 205
206 if (prof == 0)
207 {
208 qDebug("SyncPrefWidget_Conftlict::saveSettings: something is wrong, because resource does have no syncprofile" );
209 return;
362} 210}
363void KOSyncPrefsDialog::fillFTP() 211
212 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
213 prof->setSyncPrefs( syncprefs );
214
215}
216
217
218/***********************************************************************
219 *
220 *
221 **********************************************************************/
222
223SyncPrefWidget_Remote::SyncPrefWidget_Remote(QWidget *parent, const char *name) :
224 KRES::SyncWidget(parent, name)
364{ 225{
365 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 226 init();
366 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 227}
367 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 228
368 229
230SyncPrefWidget_Remote::~SyncPrefWidget_Remote()
231{
369} 232}
370void KOSyncPrefsDialog::kindChanged( bool b ) 233
234void SyncPrefWidget_Remote::init()
371{ 235{
236 QLabel * lab;
237 QPushButton* button;
238
239
240 QGridLayout *topLayout = new QGridLayout( this, 6,2 );
241 topLayout->setMargin( KDialog::marginHint() );
242 topLayout->setSpacing( KDialog::spacingHint() );
243
244 int iii = 0;
245
246 QButtonGroup* gr;
247
248 QButtonGroup *proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), this);
249 gr = proGr;
250 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
251 ++iii;
252 mProfileKind = new QComboBox( gr );
253
254 mProfileKind->insertItem( i18n("Local file"), Local );
255 mProfileKind->insertItem( i18n("Remote file (w down/upload cmd)"),Remote );
256 mProfileKind->insertItem( i18n("Mobile device (cell phone)"), Mobile );
257
258 connect( mProfileKind, SIGNAL( activated( int ) ),
259 this, SLOT (kindChanged( int ) ) );
372 260
373 localFileWidget->setEnabled(b); 261
374 remoteFileWidget->setEnabled(!b); 262 QHBox* temphb;
263
264 remoteFileWidget = new QVBox( this);
265 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
266 ++iii;
267 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
268 mRemotePrecommand = new QLineEdit(remoteFileWidget);
269
270 lab = new QLabel( i18n("Local temp file (=Location):"), remoteFileWidget);
271 mLocalTempFile = new QLineEdit(remoteFileWidget);
272 mLocalTempFile->setEnabled(false);
273
274
275 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
276 mRemotePostcommand = new QLineEdit(remoteFileWidget);
277
278 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
279 temphb = new QHBox( remoteFileWidget );
280 button = new QPushButton( i18n("ssh/scp"), temphb );
281 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
282 button = new QPushButton( i18n("ftp"), temphb );
283 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
284 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
375 285
376} 286}
377void KOSyncPrefsDialog::deleteProfile() 287
288void SyncPrefWidget_Remote::loadSettings( KRES::Resource *res )
289{
290 KABC::Resource* resource = (KABC::Resource*)( res );
291 KSyncProfile* prof = resource->getSyncProfile();
292
293 if (prof == 0)
378{ 294{
379 //qDebug("KOSyncPrefsDialog::deleteProfile() "); 295 qDebug("SyncPrefWidget_Remote::loadSettings: something is wrong, because resource does have no syncprofile" );
380 if ( currentSelection >= 0 ) {
381 if ( currentSelection < 3 ) {
382 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
383 return; 296 return;
384 } 297 }
385 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 298
386 mSyncProfiles.remove( temp ); 299 int val;
387 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 300
388 insertProfiles(); 301 if (prof->getIsPhoneSync())
302 val = Mobile;
303 else if (!prof->getIsLocalFileSync())
304 val = Remote;
305 else // default value
306 val = Local;
307
308 mProfileKind->setCurrentItem( val );
309 kindChanged( val );
310
311
312 mRemotePrecommand->setText(prof->getPreSyncCommand());
313 mLocalTempFile->setText(resource->fileName());
314 mRemotePostcommand->setText(prof->getPostSyncCommand());
389 } 315 }
316
317void SyncPrefWidget_Remote::saveSettings( KRES::Resource *res )
318{
319 KABC::Resource* resource = (KABC::Resource*)( res );
320 KSyncProfile* prof = resource->getSyncProfile();
321
322 if (prof == 0)
323 {
324 qDebug("SyncPrefWidget_Remote::saveSettings: something is wrong, because resource does have no syncprofile" );
325 return;
390} 326}
391 327
392void KOSyncPrefsDialog::saveProfile() 328 int val = mProfileKind->currentItem();
329
330 if (val == Mobile)
331 {
332 prof->setIsLocalFileSync(true);
333 prof->setIsPhoneSync(true);
334 }
335 else if (val == Remote)
393{ 336{
394 KSyncProfile* prof; 337 prof->setIsLocalFileSync(false);
395 if ( currentSelection >= 0 ) { 338 prof->setIsPhoneSync(false);
396 prof = mSyncProfiles.at(currentSelection) ; 339 }
340 else // default value is Local
341 {
342 prof->setIsLocalFileSync(true);
343 prof->setIsPhoneSync(false);
344 }
345
346
397 prof->setPreSyncCommand( mRemotePrecommand->text()); 347 prof->setPreSyncCommand( mRemotePrecommand->text());
348//US prof->setLocalTempFile( mLocalTempFile->text());
398 prof->setPostSyncCommand( mRemotePostcommand->text() ); 349 prof->setPostSyncCommand( mRemotePostcommand->text() );
399 prof->setLocalTempFile( mLocalTempFile->text());
400 prof->setRemoteFileName( mRemoteFile->text() );
401 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
402 prof->setAskForPreferences( mAskForPreferences->isChecked());
403 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
404 prof->setWriteBackFile( mWriteBackFile->isChecked());
405 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
406 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
407 prof->setSyncPrefs( syncprefs);
408 prof->setIsLocalFileSync( mIsLocal->isChecked() );
409 } 350 }
410 351
411}
412 352
413void KOSyncPrefsDialog::insertProfiles() 353void SyncPrefWidget_Remote::fillSSH()
414{
415 int curItem = mProfileBox->currentItem();
416 mProfileBox->blockSignals( true );
417 mProfileBox->clear();
418 mProfileBox->insertStringList (mSyncProfileNames );
419 int item = mSyncProfileNames.count() -1;
420 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
421 mProfileBox->setCurrentItem( curItem );
422 else if ( item >= 0 ) {
423 mProfileBox->setCurrentItem( item );
424 }
425 currentSelection = -1;
426 if ( mSyncProfileNames.count() > 0 ) {
427 //qDebug(" profileChanged( mProfileBox->currentItem() ");
428 profileChanged( mProfileBox->currentItem() );
429 currentSelection = mProfileBox->currentItem();
430 }
431 mProfileBox->blockSignals( false );
432}
433
434void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
435{ 354{
436 saveProfile(); 355 QString location = mLocalTempFile->text();
437 mSyncProfiles.append( temp ); 356
438 mSyncProfileNames << temp->getName(); 357 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/"+location + " " + location );
439 insertProfiles(); 358//US mLocalTempFile->setText("/tmp/mycalendar.ics" );
440 int last = mProfileBox->count() -1; 359 mRemotePostcommand->setText("scp " + location + " zaurus@192.168.0.65:/home/zaurus/kdepim/"+location );
441 mProfileBox->blockSignals( true ); 360}
442 mProfileBox->setCurrentItem( last ); 361
443 mProfileBox->blockSignals( false ); 362void SyncPrefWidget_Remote::fillFTP()
444 profileChanged(last);
445}
446void KOSyncPrefsDialog::newProfile()
447{ 363{
448 addProfile ( new KSyncProfile () ); 364 QString location = mLocalTempFile->text();
365
366 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/" + location );
367//US mLocalTempFile->setText("/tmp/mycalendar.ics" );
368 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/"+location+ " " + location);
369
449} 370}
450 371
451void KOSyncPrefsDialog::cloneProfile() 372
373void SyncPrefWidget_Remote::kindChanged( int newKind )
452{ 374{
453 if ( currentSelection >= 0 ) 375
454 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 376 if (newKind == Mobile)
455 else 377 remoteFileWidget->setEnabled(false);
456 newProfile(); 378 else if (newKind == Remote)
379 remoteFileWidget->setEnabled(true);
380 else // default value is local
381 remoteFileWidget->setEnabled(false);
382
457} 383}
458 384
385/***********************************************************************
386 *
387 *
388 **********************************************************************/
459 389
460void KOSyncPrefsDialog::usrReadConfig() 390
391SyncPrefWidgetContainer::SyncPrefWidgetContainer()
392 : SyncWidgetContainer()
461{ 393{
462 KConfig *config = KOGlobals::config();
463 config->setGroup("SyncProfiles");
464 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames;
465 int i;
466 KSyncProfile* temp ;
467 mSyncProfiles.clear();
468 for ( i = 0; i < mSyncProfileNames.count();++i ) {
469 temp = new KSyncProfile ();
470 temp->setName( mSyncProfileNames[i] );
471 temp->readConfig( config );
472 mSyncProfiles.append( temp );
473 } 394 }
474 insertProfiles(); 395
475 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 396KRES::SyncWidget* SyncPrefWidgetContainer::generateSettingsTab(QWidget *parent = 0, const char *name = 0)
397{
398 return new SyncPrefWidget_Settings(parent, name);
476} 399}
477 400
401KRES::SyncWidget* SyncPrefWidgetContainer::generateConflictsTab(QWidget *parent = 0, const char *name = 0)
402{
403 return new SyncPrefWidget_Conflict(parent, name);
404}
478 405
479void KOSyncPrefsDialog::usrWriteConfig() 406KRES::SyncWidget* SyncPrefWidgetContainer::generateRemoteTab(QWidget *parent = 0, const char *name = 0)
480{ 407{
481 saveProfile(); 408 return new SyncPrefWidget_Remote(parent, name);
482 if ( currentSelection >= 0 )
483 profileChanged(currentSelection);
484 KConfig *config = KOGlobals::config();
485 config->setGroup("SyncProfiles");
486 KSyncProfile* prof = mSyncProfiles.first();
487 while ( prof ) {
488 prof->writeConfig(config);
489 prof = mSyncProfiles.next();
490 }
491 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
492 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
493 config->writeEntry("SyncProfileNames",&mSyncProfileNames);
494} 409}
495*/ 410
diff --git a/kabc/syncprefwidget.h b/kabc/syncprefwidget.h
index 3709d78..b20a68e 100644
--- a/kabc/syncprefwidget.h
+++ b/kabc/syncprefwidget.h
@@ -21,101 +21,119 @@
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef _SYNCPREFWIDGET_H 28#ifndef _SYNCPREFWIDGET_H
29#define _SYNCPREFWIDGET_H 29#define _SYNCPREFWIDGET_H
30 30
31#include <kresources/syncwidget.h> 31#include <kresources/syncwidget.h>
32 32
33/*US
34//#include <qframe.h>
35//#include <qdict.h>
36#include <qvbox.h>
37#include <qhbox.h>
38//#include <qcolor.h>
39//#include <qlistview.h>
40
41#include <kdialogbase.h>
42
43#include <libkdepim/kprefsdialog.h>
44*/
45
46//US class KColorButton;
47//US class QSpinBox;;
48class QRadioButton; 33class QRadioButton;
49class QCheckBox; 34class QCheckBox;
50class QVBox; 35class QVBox;
51//US class QSlider; 36class QComboBox;
52//US class KURLRequester;
53//US class QComboBox;
54class QLineEdit; 37class QLineEdit;
55//US class QStringList; 38class KRES::Resource;
56//US class KSyncProfile;
57 39
58 40class SyncPrefWidget_Settings : public KRES::SyncWidget
59/** Dialog to change the korganizer configuration.
60 */
61class SyncPrefWidget : public KRES::SyncWidget
62{ 41{
63 Q_OBJECT 42 Q_OBJECT
64 public: 43 public:
65 SyncPrefWidget(QWidget *parent=0); 44 SyncPrefWidget_Settings(QWidget *parent=0, const char *name = 0 );
66 ~SyncPrefWidget(); 45 ~SyncPrefWidget_Settings();
67//US void usrReadConfig();
68 46
69 public slots: 47 public slots:
70 protected slots: 48 virtual void loadSettings( KRES::Resource *resource );
71//US void accept(); 49 virtual void saveSettings( KRES::Resource *resource );
72//US void deleteProfile();
73//US void newProfile();
74//US void cloneProfile();
75//US void kindChanged(bool);
76//US void fillSSH();
77//US void fillFTP();
78//US void textChanged( const QString & );
79//US void profileChanged( int );
80//US void chooseFile();
81//US void slotOK();
82 50
83 protected:
84//US void usrWriteConfig();
85 51
52 protected:
86 void init(); 53 void init();
87 54
88 private: 55 private:
56 QCheckBox* mIncludeInRing;
57 QCheckBox* mWriteBackFile;
58 QCheckBox* mWriteBackExisting;
59 QCheckBox* mAskForPreferences;
60 QCheckBox* mShowSummaryAfterSync;
61};
89 62
90 63
91//US int currentSelection;
92//US QPtrList<KSyncProfile> mSyncProfiles;
93//US QStringList mSyncProfileNames;
94//US QLineEdit * mMyMachineName;
95//US QComboBox * mProfileBox;
96//US QRadioButton* mIsLocal;
97 QCheckBox* mIsNotLocal;
98 QCheckBox* mIncludeInRing;
99//US void addProfile ( KSyncProfile* );
100//US void insertProfiles();
101//US void saveProfile();
102//US QButtonGroup* proGr;
103 64
65class SyncPrefWidget_Conflict : public KRES::SyncWidget
66{
67 Q_OBJECT
68 public:
69 SyncPrefWidget_Conflict(QWidget *parent=0, const char *name = 0 );
70 ~SyncPrefWidget_Conflict();
71
72 public slots:
73 virtual void loadSettings( KRES::Resource *resource );
74 virtual void saveSettings( KRES::Resource *resource );
75
76 protected:
77 void init();
78
79 private:
104 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 80 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
81};
82
83
84
85
86class SyncPrefWidget_Remote : public KRES::SyncWidget
87{
88 Q_OBJECT
89 public:
90 SyncPrefWidget_Remote(QWidget *parent=0, const char *name = 0 );
91 ~SyncPrefWidget_Remote();
92
93 enum Types {
94 Local = 0,
95 Remote = 1,
96 Mobile =2
97 };
98
99
100 public slots:
101 virtual void loadSettings( KRES::Resource *resource );
102 virtual void saveSettings( KRES::Resource *resource );
105 103
104 protected slots:
105 void fillSSH();
106 void fillFTP();
107 void kindChanged( int newKind );
108
109 protected:
110 void init();
106 111
112 private:
113 QComboBox* mProfileKind;
107 QLineEdit * mRemotePostcommand; 114 QLineEdit * mRemotePostcommand;
108 QLineEdit * mRemotePrecommand; 115 QLineEdit * mRemotePrecommand;
109 QLineEdit * mRemoteFile; 116 QLineEdit * mRemoteFile;
110 QLineEdit * mLocalTempFile; 117 QLineEdit * mLocalTempFile;
111//US QWidget* mSetupSyncAlgTab;
112
113//US QVBox* localFileWidget;
114 QVBox* remoteFileWidget; 118 QVBox* remoteFileWidget;
115 QCheckBox* mWriteBackFile;
116 QCheckBox* mWriteBackExisting;
117 QCheckBox* mAskForPreferences;
118 QCheckBox* mShowSummaryAfterSync;
119}; 119};
120 120
121
122
123
124
125class SyncPrefWidgetContainer : public KRES::SyncWidgetContainer
126{
127 Q_OBJECT
128
129public:
130 SyncPrefWidgetContainer();
131
132 virtual KRES::SyncWidget* generateSettingsTab(QWidget *parent, const char *name);
133 virtual KRES::SyncWidget* generateConflictsTab(QWidget *parent, const char *name);
134 virtual KRES::SyncWidget* generateRemoteTab(QWidget *parent, const char *name);
135};
136
137
138
121#endif 139#endif