Diffstat (limited to 'kabc/plugins/dir/resourcedir.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index e2b7b08..c61664b 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp | |||
@@ -41,96 +41,103 @@ $Id$ | |||
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | //US #include <kgenericfactory.h> | 42 | //US #include <kgenericfactory.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | #include <klocale.h> | 44 | #include <klocale.h> |
45 | #include <kstandarddirs.h> | 45 | #include <kstandarddirs.h> |
46 | #include <kurlrequester.h> | 46 | #include <kurlrequester.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | 48 | ||
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | 50 | ||
51 | #include "formatfactory.h" | 51 | #include "formatfactory.h" |
52 | 52 | ||
53 | #include "resourcedirconfig.h" | 53 | #include "resourcedirconfig.h" |
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | //US | 56 | //US |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | 58 | ||
59 | #define NO_DIRWATCH | 59 | #define NO_DIRWATCH |
60 | #include "resourcedir.h" | 60 | #include "resourcedir.h" |
61 | 61 | ||
62 | //#define ALLOW_LOCKING | 62 | //#define ALLOW_LOCKING |
63 | 63 | ||
64 | using namespace KABC; | 64 | using namespace KABC; |
65 | 65 | ||
66 | extern "C" | 66 | extern "C" |
67 | #ifdef _WIN32_ | 67 | #ifdef _WIN32_ |
68 | __declspec(dllexport) | 68 | __declspec(dllexport) |
69 | #else | 69 | #else |
70 | { | 70 | { |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | //US void *init_kabc_dir() | 73 | //US void *init_kabc_dir() |
74 | void *init_microkabc_dir() | 74 | void *init_microkabc_dir() |
75 | { | 75 | { |
76 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); | 76 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); |
77 | } | 77 | } |
78 | #ifndef _WIN32_ | 78 | #ifndef _WIN32_ |
79 | } | 79 | } |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | ResourceDir::ResourceDir( const KConfig *config ) | 82 | ResourceDir::ResourceDir( const KConfig *config ) |
83 | : Resource( config ) | 83 | : Resource( config ) |
84 | { | 84 | { |
85 | QString path; | 85 | QString path; |
86 | 86 | ||
87 | KConfig *cfg = (KConfig *)config; | 87 | KConfig *cfg = (KConfig *)config; |
88 | if ( cfg ) { | 88 | if ( cfg ) { |
89 | #ifdef _WIN32_ | ||
90 | // we use plugins on win32. the group is stored in a static variable | ||
91 | // such that group info not available on win32 plugins | ||
92 | // to fix that, it would be a looooot of work | ||
93 | if ( !cfg->tempGroup().isEmpty() ) | ||
94 | cfg->setGroup( cfg->tempGroup() ); | ||
95 | #endif | ||
89 | //US path = config->readEntry( "FilePath" ); | 96 | //US path = config->readEntry( "FilePath" ); |
90 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); | 97 | path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); |
91 | //US mFormatName = config->readEntry( "FileFormat" ); | 98 | //US mFormatName = config->readEntry( "FileFormat" ); |
92 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); | 99 | mFormatName = cfg->readEntry( "FileFormat", "vcard" ); |
93 | } else { | 100 | } else { |
94 | path = StdAddressBook::directoryName(); | 101 | path = StdAddressBook::directoryName(); |
95 | mFormatName = "vcard"; | 102 | mFormatName = "vcard"; |
96 | } | 103 | } |
97 | 104 | ||
98 | 105 | ||
99 | FormatFactory *factory = FormatFactory::self(); | 106 | FormatFactory *factory = FormatFactory::self(); |
100 | mFormat = factory->format( mFormatName ); | 107 | mFormat = factory->format( mFormatName ); |
101 | 108 | ||
102 | if ( !mFormat ) { | 109 | if ( !mFormat ) { |
103 | mFormatName = "vcard"; | 110 | mFormatName = "vcard"; |
104 | mFormat = factory->format( mFormatName ); | 111 | mFormat = factory->format( mFormatName ); |
105 | } | 112 | } |
106 | 113 | ||
107 | /*US | 114 | /*US |
108 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); | 115 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); |
109 | if (mFormatName == "vcard") | 116 | if (mFormatName == "vcard") |
110 | mFormat = new VCardFormatPlugin2(); | 117 | mFormat = new VCardFormatPlugin2(); |
111 | else if (mFormatName == "binary") | 118 | else if (mFormatName == "binary") |
112 | mFormat = new BinaryFormat(); | 119 | mFormat = new BinaryFormat(); |
113 | else | 120 | else |
114 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); | 121 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); |
115 | */ | 122 | */ |
116 | #ifndef NO_DIRWATCH | 123 | #ifndef NO_DIRWATCH |
117 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); | 124 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); |
118 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); | 125 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); |
119 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); | 126 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); |
120 | #endif | 127 | #endif |
121 | setPath( path ); | 128 | setPath( path ); |
122 | } | 129 | } |
123 | 130 | ||
124 | ResourceDir::~ResourceDir() | 131 | ResourceDir::~ResourceDir() |
125 | { | 132 | { |
126 | delete mFormat; | 133 | delete mFormat; |
127 | mFormat = 0; | 134 | mFormat = 0; |
128 | } | 135 | } |
129 | 136 | ||
130 | void ResourceDir::writeConfig( KConfig *config ) | 137 | void ResourceDir::writeConfig( KConfig *config ) |
131 | { | 138 | { |
132 | config->setGroup( "Resource_" + identifier() ); | 139 | config->setGroup( "Resource_" + identifier() ); |
133 | Resource::writeConfig( config ); | 140 | Resource::writeConfig( config ); |
134 | 141 | ||
135 | config->writeEntry( "FilePath", mPath ); | 142 | config->writeEntry( "FilePath", mPath ); |
136 | config->writeEntry( "FileFormat", mFormatName ); | 143 | config->writeEntry( "FileFormat", mFormatName ); |