-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | libkdepim/externalapphandler.cpp | 36 |
2 files changed, 22 insertions, 16 deletions
@@ -1,51 +1,51 @@ | |||
1 | ############################################################################# | 1 | ############################################################################# |
2 | # Makefile for building: kopi-desktop | 2 | # Makefile for building: kopi-desktop |
3 | # Generated by qmake (1.07a) (Qt 3.3.3) on: Mon Aug 9 13:18:13 2004 | 3 | # Generated by qmake (1.07a) (Qt 3.3.3) on: Tue Aug 10 18:20:15 2004 |
4 | # Project: kopi-desktop.pro | 4 | # Project: kopi-desktop.pro |
5 | # Template: subdirs | 5 | # Template: subdirs |
6 | # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro | 6 | # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro |
7 | ############################################################################# | 7 | ############################################################################# |
8 | 8 | ||
9 | MAKEFILE =Makefile | 9 | MAKEFILE =Makefile |
10 | QMAKE =qmake | 10 | QMAKE =qmake |
11 | DEL_FILE = rm -f | 11 | DEL_FILE = rm -f |
12 | CHK_DIR_EXISTS= test -d | 12 | CHK_DIR_EXISTS= test -d |
13 | MKDIR = mkdir -p | 13 | MKDIR = mkdir -p |
14 | INSTALL_FILE= | 14 | INSTALL_FILE= |
15 | INSTALL_DIR = | 15 | INSTALL_DIR = |
16 | SUBTARGETS = \ | 16 | SUBTARGETS = \ |
17 | sub-gammu-emb-common \ | 17 | sub-gammu-emb-common \ |
18 | sub-libical \ | 18 | sub-libical \ |
19 | sub-libkcal \ | 19 | sub-libkcal \ |
20 | sub-microkde \ | 20 | sub-microkde \ |
21 | sub-libkdepim \ | 21 | sub-libkdepim \ |
22 | sub-kabc \ | 22 | sub-kabc \ |
23 | sub-korganizer \ | 23 | sub-korganizer \ |
24 | sub-kaddressbook \ | 24 | sub-kaddressbook \ |
25 | sub-kabc-plugins-file \ | 25 | sub-kabc-plugins-file \ |
26 | sub-kabc-plugins-dir | 26 | sub-kabc-plugins-dir |
27 | 27 | ||
28 | first: all | 28 | first: all |
29 | 29 | ||
30 | all: Makefile $(SUBTARGETS) | 30 | all: Makefile $(SUBTARGETS) |
31 | 31 | ||
32 | gammu/emb/common/$(MAKEFILE): | 32 | gammu/emb/common/$(MAKEFILE): |
33 | @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" | 33 | @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" |
34 | cd gammu/emb/common && $(QMAKE) common.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 34 | cd gammu/emb/common && $(QMAKE) common.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
35 | sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE | 35 | sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE |
36 | cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) | 36 | cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) |
37 | 37 | ||
38 | libical/$(MAKEFILE): | 38 | libical/$(MAKEFILE): |
39 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" | 39 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" |
40 | cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 40 | cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
41 | sub-libical: libical/$(MAKEFILE) FORCE | 41 | sub-libical: libical/$(MAKEFILE) FORCE |
42 | cd libical && $(MAKE) -f $(MAKEFILE) | 42 | cd libical && $(MAKE) -f $(MAKEFILE) |
43 | 43 | ||
44 | libkcal/$(MAKEFILE): | 44 | libkcal/$(MAKEFILE): |
45 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" | 45 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" |
46 | cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 46 | cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
47 | sub-libkcal: libkcal/$(MAKEFILE) FORCE | 47 | sub-libkcal: libkcal/$(MAKEFILE) FORCE |
48 | cd libkcal && $(MAKE) -f $(MAKEFILE) | 48 | cd libkcal && $(MAKE) -f $(MAKEFILE) |
49 | 49 | ||
50 | microkde/$(MAKEFILE): | 50 | microkde/$(MAKEFILE): |
51 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" | 51 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" |
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 6f812d0..0128cf7 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,87 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
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 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | ||
34 | 35 | ||
35 | 36 | #ifndef DESKTOP_VERSION | |
36 | #include <qtopia/qcopenvelope_qws.h> | 37 | #include <qtopia/qcopenvelope_qws.h> |
37 | 38 | #endif | |
38 | 39 | ||
39 | #include <kstaticdeleter.h> | 40 | #include <kstaticdeleter.h> |
41 | #include <kmessagebox.h> | ||
40 | 42 | ||
41 | 43 | ||
42 | #include "externalapphandler.h" | 44 | #include "externalapphandler.h" |
43 | 45 | ||
44 | #include "kpimglobalprefs.h" | 46 | #include "kpimglobalprefs.h" |
45 | 47 | ||
46 | 48 | ||
47 | 49 | ||
48 | 50 | ||
49 | 51 | ||
50 | 52 | ||
51 | 53 | ||
52 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 54 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
53 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 55 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
54 | 56 | ||
55 | 57 | ||
56 | ExternalAppHandler::ExternalAppHandler() | 58 | ExternalAppHandler::ExternalAppHandler() |
57 | { | 59 | { |
58 | mDefaultItems.setAutoDelete(true); | 60 | mDefaultItems.setAutoDelete(true); |
59 | } | 61 | } |
60 | 62 | ||
61 | ExternalAppHandler::~ExternalAppHandler() | 63 | ExternalAppHandler::~ExternalAppHandler() |
62 | { | 64 | { |
63 | } | 65 | } |
64 | 66 | ||
65 | void ExternalAppHandler::loadConfig() | 67 | void ExternalAppHandler::loadConfig() |
66 | { | 68 | { |
67 | mDefaultItems.clear(); | 69 | mDefaultItems.clear(); |
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 73 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
72 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 74 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
73 | 75 | ||
74 | if (opiepath.isEmpty()) | 76 | if (opiepath.isEmpty()) |
75 | opiepath = qtopiapath; | 77 | opiepath = qtopiapath; |
76 | 78 | ||
77 | //mailclients | 79 | //mailclients |
78 | QString mailmsg1 = "writeMail(QString,QString)"; | 80 | QString mailmsg1 = "writeMail(QString,QString)"; |
79 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 81 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
80 | 82 | ||
81 | QString undefined = "undefined"; | 83 | QString undefined = "undefined"; |
82 | 84 | ||
83 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 85 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
84 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 86 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
85 | 87 | ||
86 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 88 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
87 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 89 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
@@ -123,404 +125,408 @@ ExternalAppHandler *ExternalAppHandler::instance() | |||
123 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 125 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
124 | sInstance->loadConfig(); | 126 | sInstance->loadConfig(); |
125 | } | 127 | } |
126 | 128 | ||
127 | return sInstance; | 129 | return sInstance; |
128 | } | 130 | } |
129 | 131 | ||
130 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | 132 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) |
131 | { | 133 | { |
132 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 134 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
133 | 135 | ||
134 | mDefaultItems.append(dai); | 136 | mDefaultItems.append(dai); |
135 | } | 137 | } |
136 | 138 | ||
137 | 139 | ||
138 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 140 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
139 | { | 141 | { |
140 | QList<DefaultAppItem> list; | 142 | QList<DefaultAppItem> list; |
141 | 143 | ||
142 | DefaultAppItem* dai; | 144 | DefaultAppItem* dai; |
143 | 145 | ||
144 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 146 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
145 | { | 147 | { |
146 | if (dai->_type == type) | 148 | if (dai->_type == type) |
147 | list.append(dai); | 149 | list.append(dai); |
148 | } | 150 | } |
149 | 151 | ||
150 | return list; | 152 | return list; |
151 | } | 153 | } |
152 | 154 | ||
153 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 155 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
154 | { | 156 | { |
155 | DefaultAppItem* dai; | 157 | DefaultAppItem* dai; |
156 | 158 | ||
157 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 159 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
158 | { | 160 | { |
159 | if (dai->_type == type && dai->_id == clientid) | 161 | if (dai->_type == type && dai->_id == clientid) |
160 | return dai; | 162 | return dai; |
161 | } | 163 | } |
162 | 164 | ||
163 | return 0; | 165 | return 0; |
164 | } | 166 | } |
165 | 167 | ||
166 | 168 | ||
167 | 169 | ||
168 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 170 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
169 | bool ExternalAppHandler::mailAttachments( const QString& urls ) | 171 | bool ExternalAppHandler::mailAttachments( const QString& urls ) |
170 | { | 172 | { |
171 | #ifndef QT_NO_COP | 173 | |
174 | #ifndef DESKTOP_VERSION | ||
172 | QString channel; | 175 | QString channel; |
173 | QString message2; | 176 | QString message2; |
174 | QString parameters2; | 177 | QString parameters2; |
175 | 178 | ||
176 | 179 | ||
177 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 180 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
178 | if (client == KPimGlobalPrefs::OTHER_EMC) | 181 | if (client == KPimGlobalPrefs::OTHER_EMC) |
179 | { | 182 | { |
180 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 183 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
181 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 184 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
182 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 185 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
183 | } | 186 | } |
184 | else | 187 | else |
185 | { | 188 | { |
186 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 189 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
187 | if (!dai) | 190 | if (!dai) |
188 | { | 191 | { |
189 | qDebug("could not find configured email application."); | 192 | qDebug("could not find configured email application."); |
190 | return false; | 193 | return false; |
191 | } | 194 | } |
192 | channel = dai->_channel; | 195 | channel = dai->_channel; |
193 | message2 = dai->_message2; | 196 | message2 = dai->_message2; |
194 | parameters2 = dai->_parameters2; | 197 | parameters2 = dai->_parameters2; |
195 | } | 198 | } |
196 | 199 | ||
197 | 200 | ||
198 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 201 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
199 | qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); | 202 | qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); |
200 | 203 | ||
204 | |||
201 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 205 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
202 | //US we need no names in the To field. The emailadresses are enough | 206 | //US we need no names in the To field. The emailadresses are enough |
203 | 207 | ||
204 | passParameter(&e, parameters2, urls); | 208 | passParameter(&e, parameters2, urls); |
205 | 209 | ||
206 | 210 | ||
211 | |||
207 | #else | 212 | #else |
208 | KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) ); | 213 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
209 | #endif | 214 | #endif |
210 | 215 | ||
211 | return true; | 216 | return true; |
212 | } | 217 | } |
213 | 218 | ||
214 | 219 | ||
215 | 220 | ||
216 | //calls the emailapplication and creates a mail with parameter emails as recipients | 221 | //calls the emailapplication and creates a mail with parameter emails as recipients |
217 | bool ExternalAppHandler::mailToContacts( const QString& emails ) | 222 | bool ExternalAppHandler::mailToContacts( const QString& emails ) |
218 | { | 223 | { |
219 | #ifndef QT_NO_COP | 224 | #ifndef DESKTOP_VERSION |
220 | QString channel; | 225 | QString channel; |
221 | QString message; | 226 | QString message; |
222 | QString parameters; | 227 | QString parameters; |
223 | 228 | ||
224 | 229 | ||
225 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 230 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
226 | if (client == KPimGlobalPrefs::OTHER_EMC) | 231 | if (client == KPimGlobalPrefs::OTHER_EMC) |
227 | { | 232 | { |
228 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 233 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
229 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 234 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
230 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 235 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
231 | } | 236 | } |
232 | else | 237 | else |
233 | { | 238 | { |
234 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 239 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
235 | if (!dai) | 240 | if (!dai) |
236 | { | 241 | { |
237 | qDebug("could not find configured email application."); | 242 | qDebug("could not find configured email application."); |
238 | return false; | 243 | return false; |
239 | } | 244 | } |
240 | channel = dai->_channel; | 245 | channel = dai->_channel; |
241 | message = dai->_message; | 246 | message = dai->_message; |
242 | parameters = dai->_parameters; | 247 | parameters = dai->_parameters; |
243 | } | 248 | } |
244 | 249 | ||
245 | 250 | ||
246 | //first check if one of the mailers need the emails right in the message. | 251 | //first check if one of the mailers need the emails right in the message. |
247 | message = translateMessage(message, emails); | 252 | message = translateMessage(message, emails); |
248 | 253 | ||
249 | 254 | ||
250 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 255 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
251 | qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); | 256 | qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); |
252 | 257 | ||
253 | QCopEnvelope e(channel.latin1(), message.latin1()); | 258 | QCopEnvelope e(channel.latin1(), message.latin1()); |
254 | //US we need no names in the To field. The emailadresses are enough | 259 | //US we need no names in the To field. The emailadresses are enough |
255 | 260 | ||
256 | passParameter(&e, parameters, emails); | 261 | passParameter(&e, parameters, emails); |
257 | 262 | ||
258 | 263 | ||
259 | #else | 264 | #else |
260 | KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) ); | 265 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
261 | #endif | 266 | #endif |
262 | 267 | ||
263 | 268 | ||
264 | return true; | 269 | return true; |
265 | } | 270 | } |
266 | 271 | ||
267 | 272 | ||
268 | //calls the phoneapplication with the number | 273 | //calls the phoneapplication with the number |
269 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 274 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
270 | { | 275 | { |
271 | #ifndef QT_NO_COP | 276 | #ifndef DESKTOP_VERSION |
272 | QString channel; | 277 | QString channel; |
273 | QString message; | 278 | QString message; |
274 | QString parameters; | 279 | QString parameters; |
275 | 280 | ||
276 | 281 | ||
277 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 282 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
278 | if (client == KPimGlobalPrefs::OTHER_PHC) | 283 | if (client == KPimGlobalPrefs::OTHER_PHC) |
279 | { | 284 | { |
280 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 285 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
281 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 286 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
282 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 287 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
283 | } | 288 | } |
284 | else | 289 | else |
285 | { | 290 | { |
286 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 291 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
287 | if (!dai) | 292 | if (!dai) |
288 | { | 293 | { |
289 | qDebug("could not find configured phone application."); | 294 | qDebug("could not find configured phone application."); |
290 | return false; | 295 | return false; |
291 | } | 296 | } |
292 | channel = dai->_channel; | 297 | channel = dai->_channel; |
293 | message = dai->_message; | 298 | message = dai->_message; |
294 | parameters = dai->_parameters; | 299 | parameters = dai->_parameters; |
295 | } | 300 | } |
296 | 301 | ||
297 | 302 | ||
298 | //first check if one of the mailers need the emails right in the message. | 303 | //first check if one of the mailers need the emails right in the message. |
299 | message = translateMessage(message, phonenumber); | 304 | message = translateMessage(message, phonenumber); |
300 | 305 | ||
301 | 306 | ||
302 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 307 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
303 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 308 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
304 | 309 | ||
305 | QCopEnvelope e(channel.latin1(), message.latin1()); | 310 | QCopEnvelope e(channel.latin1(), message.latin1()); |
306 | //US we need no names in the To field. The emailadresses are enough | 311 | //US we need no names in the To field. The emailadresses are enough |
307 | 312 | ||
308 | passParameter(&e, parameters, phonenumber); | 313 | passParameter(&e, parameters, phonenumber); |
309 | 314 | ||
310 | 315 | ||
311 | #else | 316 | #else |
312 | KMessageBox::sorry( this, i18n( "This version does not support phonecalls." ) ); | 317 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
313 | #endif | 318 | #endif |
314 | 319 | ||
315 | 320 | ||
316 | return true; | 321 | return true; |
317 | } | 322 | } |
318 | 323 | ||
319 | //calls the smsapplication with the number | 324 | //calls the smsapplication with the number |
320 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 325 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
321 | { | 326 | { |
322 | #ifndef QT_NO_COP | 327 | #ifndef DESKTOP_VERSION |
323 | QString channel; | 328 | QString channel; |
324 | QString message; | 329 | QString message; |
325 | QString parameters; | 330 | QString parameters; |
326 | 331 | ||
327 | 332 | ||
328 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 333 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
329 | if (client == KPimGlobalPrefs::OTHER_SMC) | 334 | if (client == KPimGlobalPrefs::OTHER_SMC) |
330 | { | 335 | { |
331 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 336 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
332 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 337 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
333 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 338 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
334 | } | 339 | } |
335 | else | 340 | else |
336 | { | 341 | { |
337 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 342 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
338 | if (!dai) | 343 | if (!dai) |
339 | { | 344 | { |
340 | qDebug("could not find configured sms application."); | 345 | qDebug("could not find configured sms application."); |
341 | return false; | 346 | return false; |
342 | } | 347 | } |
343 | channel = dai->_channel; | 348 | channel = dai->_channel; |
344 | message = dai->_message; | 349 | message = dai->_message; |
345 | parameters = dai->_parameters; | 350 | parameters = dai->_parameters; |
346 | } | 351 | } |
347 | 352 | ||
348 | 353 | ||
349 | //first check if one of the mailers need the emails right in the message. | 354 | //first check if one of the mailers need the emails right in the message. |
350 | message = translateMessage(message, phonenumber); | 355 | message = translateMessage(message, phonenumber); |
351 | 356 | ||
352 | 357 | ||
353 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 358 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
354 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 359 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
355 | 360 | ||
356 | QCopEnvelope e(channel.latin1(), message.latin1()); | 361 | QCopEnvelope e(channel.latin1(), message.latin1()); |
357 | //US we need no names in the To field. The emailadresses are enough | 362 | //US we need no names in the To field. The emailadresses are enough |
358 | 363 | ||
359 | passParameter(&e, parameters, phonenumber); | 364 | passParameter(&e, parameters, phonenumber); |
360 | 365 | ||
361 | 366 | ||
362 | #else | 367 | #else |
363 | KMessageBox::sorry( this, i18n( "This version does not support the sending of sms." ) ); | 368 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
364 | #endif | 369 | #endif |
365 | 370 | ||
366 | 371 | ||
367 | return true; | 372 | return true; |
368 | } | 373 | } |
369 | 374 | ||
370 | //calls the pagerapplication with the number | 375 | //calls the pagerapplication with the number |
371 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 376 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
372 | { | 377 | { |
373 | #ifndef QT_NO_COP | 378 | #ifndef DESKTOP_VERSION |
374 | QString channel; | 379 | QString channel; |
375 | QString message; | 380 | QString message; |
376 | QString parameters; | 381 | QString parameters; |
377 | 382 | ||
378 | 383 | ||
379 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 384 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
380 | if (client == KPimGlobalPrefs::OTHER_PAC) | 385 | if (client == KPimGlobalPrefs::OTHER_PAC) |
381 | { | 386 | { |
382 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 387 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
383 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 388 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
384 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 389 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
385 | } | 390 | } |
386 | else | 391 | else |
387 | { | 392 | { |
388 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 393 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
389 | if (!dai) | 394 | if (!dai) |
390 | { | 395 | { |
391 | qDebug("could not find configured pager application."); | 396 | qDebug("could not find configured pager application."); |
392 | return false; | 397 | return false; |
393 | } | 398 | } |
394 | channel = dai->_channel; | 399 | channel = dai->_channel; |
395 | message = dai->_message; | 400 | message = dai->_message; |
396 | parameters = dai->_parameters; | 401 | parameters = dai->_parameters; |
397 | } | 402 | } |
398 | 403 | ||
399 | 404 | ||
400 | //first check if one of the mailers need the emails right in the message. | 405 | //first check if one of the mailers need the emails right in the message. |
401 | message = translateMessage(message, pagernumber); | 406 | message = translateMessage(message, pagernumber); |
402 | 407 | ||
403 | 408 | ||
404 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 409 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
405 | qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 410 | qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
406 | 411 | ||
407 | QCopEnvelope e(channel.latin1(), message.latin1()); | 412 | QCopEnvelope e(channel.latin1(), message.latin1()); |
408 | //US we need no names in the To field. The emailadresses are enough | 413 | //US we need no names in the To field. The emailadresses are enough |
409 | 414 | ||
410 | passParameter(&e, parameters, pagernumber); | 415 | passParameter(&e, parameters, pagernumber); |
411 | 416 | ||
412 | 417 | ||
413 | #else | 418 | #else |
414 | KMessageBox::sorry( this, i18n( "This version does not support paging." ) ); | 419 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
415 | #endif | 420 | #endif |
416 | 421 | ||
417 | 422 | ||
418 | return true; | 423 | return true; |
419 | } | 424 | } |
420 | 425 | ||
421 | //calls the faxapplication with the number | 426 | //calls the faxapplication with the number |
422 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 427 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
423 | { | 428 | { |
424 | #ifndef QT_NO_COP | 429 | #ifndef DESKTOP_VERSION |
425 | QString channel; | 430 | QString channel; |
426 | QString message; | 431 | QString message; |
427 | QString parameters; | 432 | QString parameters; |
428 | 433 | ||
429 | 434 | ||
430 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 435 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
431 | if (client == KPimGlobalPrefs::OTHER_FAC) | 436 | if (client == KPimGlobalPrefs::OTHER_FAC) |
432 | { | 437 | { |
433 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 438 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
434 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 439 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
435 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 440 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
436 | } | 441 | } |
437 | else | 442 | else |
438 | { | 443 | { |
439 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 444 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
440 | if (!dai) | 445 | if (!dai) |
441 | { | 446 | { |
442 | qDebug("could not find configured fax application."); | 447 | qDebug("could not find configured fax application."); |
443 | return false; | 448 | return false; |
444 | } | 449 | } |
445 | channel = dai->_channel; | 450 | channel = dai->_channel; |
446 | message = dai->_message; | 451 | message = dai->_message; |
447 | parameters = dai->_parameters; | 452 | parameters = dai->_parameters; |
448 | } | 453 | } |
449 | 454 | ||
450 | 455 | ||
451 | //first check if one of the mailers need the emails right in the message. | 456 | //first check if one of the mailers need the emails right in the message. |
452 | message = translateMessage(message, faxnumber); | 457 | message = translateMessage(message, faxnumber); |
453 | 458 | ||
454 | 459 | ||
455 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 460 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
456 | qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 461 | qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
457 | 462 | ||
458 | QCopEnvelope e(channel.latin1(), message.latin1()); | 463 | QCopEnvelope e(channel.latin1(), message.latin1()); |
459 | //US we need no names in the To field. The emailadresses are enough | 464 | //US we need no names in the To field. The emailadresses are enough |
460 | 465 | ||
461 | passParameter(&e, parameters, faxnumber); | 466 | passParameter(&e, parameters, faxnumber); |
462 | 467 | ||
463 | 468 | ||
464 | #else | 469 | #else |
465 | KMessageBox::sorry( this, i18n( "This version does not support the sending of faxes." ) ); | 470 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
466 | #endif | 471 | #endif |
467 | 472 | ||
468 | 473 | ||
469 | return true; | 474 | return true; |
470 | } | 475 | } |
471 | 476 | ||
472 | 477 | ||
473 | 478 | ||
474 | 479 | ||
475 | 480 | ||
476 | 481 | ||
477 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const | 482 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const |
478 | { | 483 | { |
479 | return message.replace( QRegExp("%1"), param1 ); | 484 | return message.replace( QRegExp("%1"), param1 ); |
480 | } | 485 | } |
481 | 486 | ||
482 | void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const | 487 | void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const |
483 | { | 488 | { |
489 | #ifndef DESKTOP_VERSION | ||
484 | QMap<QString, QString> valmap; | 490 | QMap<QString, QString> valmap; |
485 | bool useValMap = false; | 491 | bool useValMap = false; |
486 | 492 | ||
487 | // first extract all parts of the parameters. | 493 | // first extract all parts of the parameters. |
488 | QStringList paramlist = QStringList::split(";", parameters); | 494 | QStringList paramlist = QStringList::split(";", parameters); |
489 | 495 | ||
490 | //Now check how many parts we have. | 496 | //Now check how many parts we have. |
491 | //=0 :no params to pass | 497 | //=0 :no params to pass |
492 | //>0 :parameters to pass | 498 | //>0 :parameters to pass |
493 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 499 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
494 | { | 500 | { |
495 | QString param = (*it); | 501 | QString param = (*it); |
496 | QStringList keyvallist = QStringList::split("=", param); | 502 | QStringList keyvallist = QStringList::split("=", param); |
497 | 503 | ||
498 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 504 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
499 | QStringList::Iterator it2 = keyvallist.begin(); | 505 | QStringList::Iterator it2 = keyvallist.begin(); |
500 | QString key = (*it2); | 506 | QString key = (*it2); |
501 | key = key.replace( QRegExp("%1"), param1 ); | 507 | key = key.replace( QRegExp("%1"), param1 ); |
502 | ++it2; | 508 | ++it2; |
503 | 509 | ||
504 | if(it2 != keyvallist.end()) | 510 | if(it2 != keyvallist.end()) |
505 | { | 511 | { |
506 | QString value = (*it2); | 512 | QString value = (*it2); |
507 | value = value.replace( QRegExp("%1"), param1 ); | 513 | value = value.replace( QRegExp("%1"), param1 ); |
508 | 514 | ||
509 | valmap.insert(key, value); | 515 | valmap.insert(key, value); |
510 | useValMap = true; | 516 | useValMap = true; |
511 | } | 517 | } |
512 | else | 518 | else |
513 | { | 519 | { |
514 | (*e) << key.latin1(); | 520 | (*e) << key.latin1(); |
515 | } | 521 | } |
516 | } | 522 | } |
517 | 523 | ||
518 | if (useValMap == true) | 524 | if (useValMap == true) |
519 | (*e) << valmap; | 525 | (*e) << valmap; |
520 | 526 | ||
521 | 527 | #endif | |
522 | 528 | ||
523 | } | 529 | } |
524 | 530 | ||
525 | 531 | ||
526 | 532 | ||