summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-03 23:09:08 (UTC)
committer zautrix <zautrix>2005-04-03 23:09:08 (UTC)
commit06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5 (patch) (unidiff)
treea9f01377dc21931e5d267edc3b196232f244d1fb
parent30359da3c126e67f6c75400323fcca4c159c3d93 (diff)
downloadkdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.zip
kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.gz
kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.bz2
sync fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp18
-rw-r--r--kabc/plugins/file/resourcefile.h1
2 files changed, 13 insertions, 6 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 0e6c2a3..af76558 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -63,97 +63,103 @@ __declspec(dllexport)
63#else 63#else
64{ 64{
65#endif 65#endif
66 66
67//US void *init_kabc_file() 67//US void *init_kabc_file()
68 void *init_microkabc_file() 68 void *init_microkabc_file()
69 { 69 {
70 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); 70 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
71 } 71 }
72#ifndef _WIN32_ 72#ifndef _WIN32_
73} 73}
74#endif 74#endif
75 75
76ResourceFile::ResourceFile( const KConfig *config ) 76ResourceFile::ResourceFile( const KConfig *config )
77 : Resource( config ) , mFormat( 0 ) 77 : Resource( config ) , mFormat( 0 )
78{ 78{
79 QString fileName, formatName, default_fileName; 79 QString fileName, formatName, default_fileName;
80 80
81 default_fileName = StdAddressBook::fileName(); 81 default_fileName = StdAddressBook::fileName();
82 82
83 KConfig *cfg = (KConfig *)config; 83 KConfig *cfg = (KConfig *)config;
84 if ( cfg ) { 84 if ( cfg ) {
85 fileName = cfg->readEntry( "FileName", default_fileName ); 85 fileName = cfg->readEntry( "FileName", default_fileName );
86 formatName = cfg->readEntry( "FileFormat", "vcard" ); 86 formatName = cfg->readEntry( "FileFormat", "vcard" );
87 mFamily = cfg->readEntry( "ResourceName", "std" );
87 } else { 88 } else {
88 fileName = default_fileName; 89 fileName = default_fileName;
89 formatName = "vcard"; 90 formatName = "vcard";
90 } 91 }
91 92
92 init( fileName, formatName ); 93 init( fileName, formatName );
93} 94}
94 95
95ResourceFile::ResourceFile( const QString &fileName , 96ResourceFile::ResourceFile( const QString &fileName ,
96 const QString &formatName ) 97 const QString &formatName )
97 : Resource( 0 ) 98 : Resource( 0 )
98{ 99{
99// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 100// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
100 101
101 102
102 103
103 init( fileName, formatName ); 104 init( fileName, formatName );
104} 105}
105 106
106void ResourceFile::init( const QString &fileName, const QString &formatName ) 107void ResourceFile::init( const QString &fileName, const QString &formatName )
107{ 108{
108 mFormatName = formatName; 109 mFormatName = formatName;
109 110
110 FormatFactory *factory = FormatFactory::self(); 111 FormatFactory *factory = FormatFactory::self();
111 mFormat = factory->format( mFormatName ); 112 mFormat = factory->format( mFormatName );
112 113
113 if ( !mFormat ) { 114 if ( !mFormat ) {
114 mFormatName = "vcard"; 115 mFormatName = "vcard";
115 mFormat = factory->format( mFormatName ); 116 mFormat = factory->format( mFormatName );
116 } 117 }
117 118
118#ifndef NO_DIRWATCH 119#ifndef NO_DIRWATCH
119 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 120 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
120 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 121 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
121 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 122 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
122#endif 123#endif
123 124
124 125 QString localKdeDir;
125 QString localKdeDir;
126 localKdeDir = readEnvPath("LOCALMICROKDEHOME"); 126 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
127 if ( ! localKdeDir.isEmpty() ) { 127 if ( ! localKdeDir.isEmpty() ) {
128 qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() ); 128 qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() );
129 QFileInfo fi ( fileName ); 129 QFileInfo fi ( fileName );
130 QString localname = localKdeDir + "/apps/kabc/" + fi.fileName (); 130 QString localname = localKdeDir + "/apps/kabc/" + fi.fileName ();
131 QFileInfo fi2 ( localname ); 131 QFileInfo fi2 ( localname );
132 if ( ! fi2.exists() ) { 132 if ( ! fi2.exists() || mFamily == "sync_res" ) {
133 KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") ); 133 if ( fi.exists() && mFamily == "sync_res") {
134 setFileName( localname ); 134 qDebug("LOCAL mode SYNC mode using absolute file path ");
135 return; 135 setFileName( fileName );
136 return;
137 } else {
138 KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") );
139 setFileName( localname );
140 return;
141 }
136 142
137 } else { 143 } else {
138 qDebug("Local resource file found. Changing filename to: %s",localname.latin1() ); 144 qDebug("Local resource file found. Changing filename to: %s",localname.latin1() );
139 setFileName( localname ); 145 setFileName( localname );
140 return; 146 return;
141 } 147 }
142 148
143 } 149 }
144 setFileName( fileName ); 150 setFileName( fileName );
145} 151}
146 152
147ResourceFile::~ResourceFile() 153ResourceFile::~ResourceFile()
148{ 154{
149 delete mFormat; 155 delete mFormat;
150 mFormat = 0; 156 mFormat = 0;
151} 157}
152 158
153void ResourceFile::writeConfig( KConfig *config ) 159void ResourceFile::writeConfig( KConfig *config )
154{ 160{
155 161
156 config->setGroup( "Resource_" + identifier() ); 162 config->setGroup( "Resource_" + identifier() );
157 Resource::writeConfig( config ); 163 Resource::writeConfig( config );
158 164
159 config->writeEntry( "FileName", fileName() ); 165 config->writeEntry( "FileName", fileName() );
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index dd38a9d..3e9edfc 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -126,38 +126,39 @@ public:
126 QString format() const; 126 QString format() const;
127 127
128 /** 128 /**
129 * Remove a addressee from its source. 129 * Remove a addressee from its source.
130 * This method is mainly called by KABC::AddressBook. 130 * This method is mainly called by KABC::AddressBook.
131 */ 131 */
132 virtual void removeAddressee( const Addressee& addr ); 132 virtual void removeAddressee( const Addressee& addr );
133 133
134 /** 134 /**
135 * This method is called by an error handler if the application 135 * This method is called by an error handler if the application
136 * crashed 136 * crashed
137 */ 137 */
138 virtual void cleanUp(); 138 virtual void cleanUp();
139 139
140protected slots: 140protected slots:
141 void fileChanged(); 141 void fileChanged();
142 142
143protected: 143protected:
144 void init( const QString &fileName, const QString &format ); 144 void init( const QString &fileName, const QString &format );
145 145
146 bool lock( const QString &fileName ); 146 bool lock( const QString &fileName );
147 void unlock( const QString &fileName ); 147 void unlock( const QString &fileName );
148 148
149private: 149private:
150 QString mFamily;
150 QString mFileName2; 151 QString mFileName2;
151 QString mFormatName; 152 QString mFormatName;
152 153
153 FormatPlugin *mFormat; 154 FormatPlugin *mFormat;
154 155
155 QString mLockUniqueName; 156 QString mLockUniqueName;
156#ifndef NO_DIRWATCH 157#ifndef NO_DIRWATCH
157 KDirWatch mDirWatch; 158 KDirWatch mDirWatch;
158#endif 159#endif
159}; 160};
160 161
161} 162}
162 163
163#endif 164#endif