Diffstat (limited to 'libkdepim/externalapphandler.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.h | 111 |
1 files changed, 109 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index 3cf9e06..7c8de4e 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h | |||
@@ -1,145 +1,252 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | 30 | ||
31 | #ifndef EXTERNALAPPHANDLER_H | 31 | #ifndef EXTERNALAPPHANDLER_H |
32 | #define EXTERNALAPPHANDLER_H | 32 | #define EXTERNALAPPHANDLER_H |
33 | 33 | ||
34 | #include <qobject.h> | ||
34 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qmap.h> | ||
35 | 37 | ||
36 | class QCopEnvelope; | 38 | class QCopEnvelope; |
37 | 39 | ||
38 | 40 | ||
39 | class ExternalAppHandler; | 41 | class ExternalAppHandler; |
42 | class QCopTransferItem : public QObject | ||
43 | { | ||
44 | Q_OBJECT | ||
45 | public: | ||
46 | QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | ||
47 | QCopTransferItem(); | ||
48 | |||
49 | bool sendMessageToTarget(const QString& uid, const QString& param1); | ||
50 | |||
51 | void setSourceChannel(const QString& sourceChannel); | ||
52 | |||
53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | ||
54 | |||
55 | |||
56 | signals: | ||
57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); | ||
58 | |||
59 | |||
60 | public: | ||
61 | QString _sourceChannel; | ||
62 | QString _sourceMessage; | ||
63 | QString _sourceMessageParameters; | ||
64 | QString _targetChannel; | ||
65 | QString _targetMessage; | ||
66 | QString _targetMessageParameters; | ||
67 | |||
68 | }; | ||
69 | |||
70 | /********************************************************************************* | ||
71 | * | ||
72 | ********************************************************************************/ | ||
73 | |||
74 | class QCopMapTransferItem : public QCopTransferItem | ||
75 | { | ||
76 | Q_OBJECT | ||
77 | public: | ||
78 | QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | ||
79 | |||
80 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); | ||
81 | |||
82 | |||
83 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | ||
84 | |||
85 | |||
86 | signals: | ||
87 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); | ||
88 | |||
89 | }; | ||
90 | |||
91 | /********************************************************************************* | ||
92 | * | ||
93 | ********************************************************************************/ | ||
94 | |||
95 | class QCopListTransferItem : public QCopTransferItem | ||
96 | { | ||
97 | Q_OBJECT | ||
98 | public: | ||
99 | QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | ||
100 | |||
101 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); | ||
102 | |||
103 | |||
104 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | ||
105 | |||
106 | |||
107 | signals: | ||
108 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); | ||
109 | |||
110 | }; | ||
111 | |||
112 | /********************************************************************************* | ||
113 | * | ||
114 | ********************************************************************************/ | ||
115 | |||
40 | 116 | ||
41 | class DefaultAppItem | 117 | class DefaultAppItem |
42 | { | 118 | { |
43 | public: | 119 | public: |
44 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) | 120 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) |
45 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) | 121 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) |
46 | {} | 122 | {} |
47 | 123 | ||
48 | DefaultAppItem() | 124 | DefaultAppItem() |
49 | { } | 125 | { } |
50 | 126 | ||
51 | public: | 127 | public: |
52 | int _type; | 128 | int _type; |
53 | int _id; | 129 | int _id; |
54 | QString _label; | 130 | QString _label; |
55 | QString _channel; | 131 | QString _channel; |
56 | QString _message; | 132 | QString _message; |
57 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; | 133 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; |
58 | QString _message2; | 134 | QString _message2; |
59 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; | 135 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; |
60 | 136 | ||
61 | }; | 137 | }; |
62 | 138 | ||
63 | class ExternalAppHandler | 139 | /********************************************************************************* |
140 | * | ||
141 | ********************************************************************************/ | ||
142 | |||
143 | class ExternalAppHandler : public QObject | ||
64 | { | 144 | { |
145 | Q_OBJECT | ||
65 | public: | 146 | public: |
66 | virtual ~ExternalAppHandler(); | 147 | virtual ~ExternalAppHandler(); |
67 | 148 | ||
68 | static ExternalAppHandler *instance(); | 149 | static ExternalAppHandler *instance(); |
69 | 150 | ||
70 | enum Types { | 151 | enum Types { |
71 | EMAIL = 0, | 152 | EMAIL = 0, |
72 | PHONE = 1, | 153 | PHONE = 1, |
73 | SMS = 2, | 154 | SMS = 2, |
74 | FAX = 3, | 155 | FAX = 3, |
75 | PAGER = 4 | 156 | PAGER = 4 |
76 | }; | 157 | }; |
77 | 158 | ||
78 | enum Availability { | 159 | enum Availability { |
79 | UNDEFINED = -1, | 160 | UNDEFINED = -1, |
80 | UNAVAILABLE = 0, | 161 | UNAVAILABLE = 0, |
81 | AVAILABLE = 1 | 162 | AVAILABLE = 1 |
82 | }; | 163 | }; |
83 | 164 | ||
84 | //calls the emailapplication with a number of attachments that need to be send. | 165 | //calls the emailapplication with a number of attachments that need to be send. |
85 | //either parameter can be left empty. | 166 | //either parameter can be left empty. |
86 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); | 167 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); |
87 | 168 | ||
88 | //calls the emailapplication and creates a mail with parameter emailadress as recipients | 169 | //calls the emailapplication and creates a mail with parameter emailadress as recipients |
89 | bool mailToOneContact( const QString& name, const QString& emailadress ); | 170 | bool mailToOneContact( const QString& name, const QString& emailadress ); |
90 | 171 | ||
91 | //calls the emailapplication and creates a mail with parameter as recipients | 172 | //calls the emailapplication and creates a mail with parameter as recipients |
92 | // parameters format is | 173 | // parameters format is |
93 | // NAME <EMAIL>:SUBJECT | 174 | // NAME <EMAIL>:SUBJECT |
94 | bool mailToOneContact( const QString& adressline ); | 175 | bool mailToOneContact( const QString& adressline ); |
95 | 176 | ||
96 | //calls the phoneapplication with the number | 177 | //calls the phoneapplication with the number |
97 | bool callByPhone( const QString& phonenumber ); | 178 | bool callByPhone( const QString& phonenumber ); |
98 | 179 | ||
99 | //calls the smsapplication with the number | 180 | //calls the smsapplication with the number |
100 | bool callBySMS( const QString& phonenumber ); | 181 | bool callBySMS( const QString& phonenumber ); |
101 | 182 | ||
102 | //calls the pagerapplication with the number | 183 | //calls the pagerapplication with the number |
103 | bool callByPager( const QString& pagernumber ); | 184 | bool callByPager( const QString& pagernumber ); |
104 | 185 | ||
105 | //calls the faxapplication with the number | 186 | //calls the faxapplication with the number |
106 | bool callByFax( const QString& faxnumber ); | 187 | bool callByFax( const QString& faxnumber ); |
107 | 188 | ||
108 | bool isEmailAppAvailable(); | 189 | bool isEmailAppAvailable(); |
109 | bool isSMSAppAvailable(); | 190 | bool isSMSAppAvailable(); |
110 | bool isPhoneAppAvailable(); | 191 | bool isPhoneAppAvailable(); |
111 | bool isFaxAppAvailable(); | 192 | bool isFaxAppAvailable(); |
112 | bool isPagerAppAvailable(); | 193 | bool isPagerAppAvailable(); |
113 | 194 | ||
114 | 195 | ||
196 | //Call this method on the source when you want to select names from the addressbook by using QCop | ||
197 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid); | ||
198 | //Call this method on the target when you want to return the name/email map to the source (client). | ||
199 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid); | ||
200 | |||
201 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email); | ||
202 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid); | ||
203 | |||
115 | 204 | ||
116 | //loadConfig clears the cache and checks again if the applications are available or not | 205 | //loadConfig clears the cache and checks again if the applications are available or not |
117 | void loadConfig(); | 206 | void loadConfig(); |
118 | 207 | ||
119 | QList<DefaultAppItem> getAvailableDefaultItems(Types); | 208 | QList<DefaultAppItem> getAvailableDefaultItems(Types); |
120 | DefaultAppItem* getDefaultItem(Types, int); | 209 | DefaultAppItem* getDefaultItem(Types, int); |
121 | 210 | ||
211 | public slots: | ||
212 | void appMessage( const QCString& msg, const QByteArray& data ); | ||
213 | |||
214 | |||
215 | signals: | ||
216 | // Emmitted when the target app receives a request from the source app | ||
217 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid, const QString& param1); | ||
218 | |||
219 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | ||
220 | // The first parameter is a uniqueid. It can be used to identify the event | ||
221 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | ||
222 | |||
223 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); | ||
224 | void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | ||
225 | |||
122 | 226 | ||
123 | private: | 227 | private: |
124 | ExternalAppHandler(); | 228 | ExternalAppHandler(); |
125 | QList<DefaultAppItem> mDefaultItems; | 229 | QList<DefaultAppItem> mDefaultItems; |
126 | 230 | ||
127 | Availability mEmailAppAvailable; | 231 | Availability mEmailAppAvailable; |
128 | Availability mPhoneAppAvailable; | 232 | Availability mPhoneAppAvailable; |
129 | Availability mFaxAppAvailable; | 233 | Availability mFaxAppAvailable; |
130 | Availability mSMSAppAvailable; | 234 | Availability mSMSAppAvailable; |
131 | Availability mPagerAppAvailable; | 235 | Availability mPagerAppAvailable; |
132 | 236 | ||
237 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; | ||
238 | QCopListTransferItem* mFindByEmailFromKAPITransfer; | ||
239 | |||
133 | 240 | ||
134 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); | 241 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); |
135 | 242 | ||
136 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; | 243 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; |
137 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; | 244 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; |
138 | 245 | ||
139 | 246 | ||
140 | static ExternalAppHandler *sInstance; | 247 | static ExternalAppHandler *sInstance; |
141 | 248 | ||
142 | |||
143 | }; | 249 | }; |
144 | 250 | ||
251 | |||
145 | #endif | 252 | #endif |