Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 163f2b4..dc5932f 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -30,97 +30,93 @@ $Id$ | |||
30 | #ifndef _WIN32_ | 30 | #ifndef _WIN32_ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | 46 | ||
47 | #include "formatfactory.h" | 47 | #include "formatfactory.h" |
48 | 48 | ||
49 | #include "resource.h" | 49 | #include "resource.h" |
50 | #include "resourcefileconfig.h" | 50 | #include "resourcefileconfig.h" |
51 | #include "stdaddressbook.h" | 51 | #include "stdaddressbook.h" |
52 | #define NO_DIRWATCH | 52 | #define NO_DIRWATCH |
53 | #include "resourcefile.h" | 53 | #include "resourcefile.h" |
54 | #include "syncprefwidget.h" | ||
55 | 54 | ||
56 | //#define ALLOW_LOCKING | 55 | //#define ALLOW_LOCKING |
57 | 56 | ||
58 | 57 | ||
59 | 58 | ||
60 | using namespace KABC; | 59 | using namespace KABC; |
61 | 60 | ||
62 | extern "C" | 61 | extern "C" |
63 | #ifdef _WIN32_ | 62 | #ifdef _WIN32_ |
64 | __declspec(dllexport) | 63 | __declspec(dllexport) |
65 | #else | 64 | #else |
66 | { | 65 | { |
67 | #endif | 66 | #endif |
68 | 67 | ||
69 | //US void *init_kabc_file() | 68 | //US void *init_kabc_file() |
70 | void *init_microkabc_file() | 69 | void *init_microkabc_file() |
71 | { | 70 | { |
72 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); | 71 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); |
73 | } | 72 | } |
74 | #ifndef _WIN32_ | 73 | #ifndef _WIN32_ |
75 | } | 74 | } |
76 | #endif | 75 | #endif |
77 | 76 | ||
78 | ResourceFile::ResourceFile( const KConfig *config, bool syncable ) | 77 | ResourceFile::ResourceFile( const KConfig *config ) |
79 | : Resource( config, syncable ) , mFormat( 0 ) | 78 | : Resource( config ) , mFormat( 0 ) |
80 | { | 79 | { |
81 | QString fileName, formatName, default_fileName; | 80 | QString fileName, formatName, default_fileName; |
82 | 81 | ||
83 | if (syncable == true) | 82 | default_fileName = StdAddressBook::fileName(); |
84 | default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf"; | ||
85 | else | ||
86 | default_fileName = StdAddressBook::fileName(); | ||
87 | 83 | ||
88 | KConfig *cfg = (KConfig *)config; | 84 | KConfig *cfg = (KConfig *)config; |
89 | if ( cfg ) { | 85 | if ( cfg ) { |
90 | fileName = cfg->readEntry( "FileName", default_fileName ); | 86 | fileName = cfg->readEntry( "FileName", default_fileName ); |
91 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 87 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
92 | } else { | 88 | } else { |
93 | fileName = default_fileName; | 89 | fileName = default_fileName; |
94 | formatName = "vcard"; | 90 | formatName = "vcard"; |
95 | } | 91 | } |
96 | 92 | ||
97 | init( fileName, formatName ); | 93 | init( fileName, formatName ); |
98 | } | 94 | } |
99 | 95 | ||
100 | ResourceFile::ResourceFile( const QString &fileName, bool syncable , | 96 | ResourceFile::ResourceFile( const QString &fileName , |
101 | const QString &formatName ) | 97 | const QString &formatName ) |
102 | : Resource( 0, syncable ) | 98 | : Resource( 0 ) |
103 | { | 99 | { |
104 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 100 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
105 | init( fileName, formatName ); | 101 | init( fileName, formatName ); |
106 | } | 102 | } |
107 | 103 | ||
108 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 104 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
109 | { | 105 | { |
110 | mFormatName = formatName; | 106 | mFormatName = formatName; |
111 | 107 | ||
112 | FormatFactory *factory = FormatFactory::self(); | 108 | FormatFactory *factory = FormatFactory::self(); |
113 | mFormat = factory->format( mFormatName ); | 109 | mFormat = factory->format( mFormatName ); |
114 | 110 | ||
115 | if ( !mFormat ) { | 111 | if ( !mFormat ) { |
116 | mFormatName = "vcard"; | 112 | mFormatName = "vcard"; |
117 | mFormat = factory->format( mFormatName ); | 113 | mFormat = factory->format( mFormatName ); |
118 | } | 114 | } |
119 | 115 | ||
120 | #ifndef NO_DIRWATCH | 116 | #ifndef NO_DIRWATCH |
121 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 117 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
122 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 118 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
123 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 119 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
124 | #endif | 120 | #endif |
125 | setFileName( fileName ); | 121 | setFileName( fileName ); |
126 | } | 122 | } |