|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
1 #include "qmessageglobal.h" |
41 #include "qmessageglobal.h" |
2 #include "qmessagemanager.h" |
42 #include "qmessagemanager.h" |
3 #include "qmessageaccount.h" |
43 #include "qmessageaccount.h" |
4 #include "qmessageaccountid.h" |
44 #include "qmessageaccountid.h" |
5 #include "qmessageaccount_p.h" |
45 #include "qmessageaccount_p.h" |
31 return telepathyEngine(); |
70 return telepathyEngine(); |
32 } |
71 } |
33 |
72 |
34 bool TelepathyEngine::sendMessage(QMessage &message) |
73 bool TelepathyEngine::sendMessage(QMessage &message) |
35 { |
74 { |
36 QMessage::Type type=message.type(); |
75 bool retVal=false; |
37 QString cm=type == QMessage::Sms ? "ring" : type == QMessage::Xmpp ? "gabble" : ""; |
76 QMessage::Type type=message.type(); |
38 QMessageAddressList toList=message.to(); |
77 QMessageAccountId account=message.parentAccountId(); |
39 QMessageAccountId account=message.parentAccountId(); |
78 QString cm=type == QMessage::Sms ? "ring" : type == QMessage::InstantMessage ? account.toString() : ""; |
40 if(!cm.isEmpty()) { |
79 QMessageAddressList toList=message.to(); |
41 foreach(QMessageAddress to,toList) { |
80 if(!cm.isEmpty()) { |
42 tpSession->sendMessageToAddress(cm,to.recipient(),message.textContent()); |
81 foreach(QMessageAddress to,toList) { |
43 }; |
82 tpSession->sendMessageToAddress(cm,to.addressee(),message.textContent()); |
44 } |
83 retVal=true; |
45 else |
84 }; |
46 qDebug() << "TelepathyEngine::sendMessage unsupported message type" << type; |
85 } |
|
86 else |
|
87 qDebug() << "TelepathyEngine::sendMessage unsupported message type" << type; |
|
88 return retVal; |
47 } |
89 } |
48 |
90 |
49 |
91 |
50 |
92 |
51 bool TelepathyEngine::queryMessages(QMessageService& messageService, const QMessageFilter &filter, const QMessageSortOrder &sortOrder, uint limit, uint offset) const |
|
52 { |
|
53 return true; |
|
54 } |
|
55 |
|
56 bool TelepathyEngine::queryMessages(QMessageService& messageService, const QMessageFilter &filter, const QString &body, QMessageDataComparator::MatchFlags matchFlags, const QMessageSortOrder &sortOrder, uint limit, uint offset) const |
|
57 { |
|
58 return true; |
|
59 } |
|
60 |
|
61 bool TelepathyEngine::countMessages(QMessageService& messageService, const QMessageFilter &filter) |
|
62 { |
|
63 return true; |
|
64 }; |
|
65 |
93 |
66 void TelepathyEngine::updateImAccounts() const |
94 void TelepathyEngine::updateImAccounts() const |
67 { |
95 { |
68 // iDefaultImAccountId = QMessageAccountId(); |
96 // iDefaultImAccountId = QMessageAccountId(); |
|
97 // qDebug() << "TelepathyEngine::updateImAccounts"; |
69 iAccounts.clear(); |
98 iAccounts.clear(); |
70 foreach (TpSessionAccount *tpacc, tpSession->accounts) { |
99 foreach (TpSessionAccount *tpacc, tpSession->accounts) { |
71 qDebug() << "TelepathyEngine::updateImAccounts" << tpacc->acc->cmName() << " " << tpacc->acc->protocol() << " " << tpacc->acc->displayName(); |
100 // qDebug() << "TelepathyEngine::updateImAccounts" << tpacc->acc->cmName() << " " << tpacc->acc->protocol() << " " << tpacc->acc->displayName(); |
72 bool account_ok = tpacc->acc->isEnabled() && tpacc->acc->isValidAccount(); |
101 bool account_ok = tpacc->acc->isEnabled() && tpacc->acc->isValidAccount(); |
73 QString cm=tpacc->acc->cmName(); |
102 QString cm=tpacc->acc->cmName(); |
74 if (account_ok) { |
103 if (account_ok) { |
75 if(cm=="ring") { // Ring connection manager for cellular telephony |
104 if(cm=="ring") { // Ring connection manager for cellular telephony |
76 QString accountId = tpacc->acc->uniqueIdentifier(); |
105 QString accountId = tpacc->acc->uniqueIdentifier(); |
87 QString accountId = tpacc->acc->uniqueIdentifier(); |
116 QString accountId = tpacc->acc->uniqueIdentifier(); |
88 QString accountName = tpacc->acc->normalizedName(); |
117 QString accountName = tpacc->acc->normalizedName(); |
89 QString accountAddress = tpacc->acc->normalizedName(); |
118 QString accountAddress = tpacc->acc->normalizedName(); |
90 QMessageAccount account = QMessageAccountPrivate::from(QMessageAccountId(accountId), |
119 QMessageAccount account = QMessageAccountPrivate::from(QMessageAccountId(accountId), |
91 accountName, |
120 accountName, |
92 QMessageAddress(QMessageAddress::Xmpp, accountAddress), |
121 QMessageAddress(QMessageAddress::InstantMessage, accountAddress), |
93 QMessage::Xmpp); |
122 QMessage::InstantMessage); |
94 iAccounts.insert(accountId, account); |
123 iAccounts.insert(accountId, account); |
95 } else qDebug() << "Protocol " << tpacc->acc->protocol() << "with connectionmanager " << cm << "Is not yet supported"; |
124 } else qDebug() << "Protocol " << tpacc->acc->protocol() << "with connectionmanager " << cm << "Is not yet supported"; |
96 // if (strncmp(account_name_key, default_account, strlen(default_account))) iDefaultEmailAccountId = accountId; |
125 // if (strncmp(account_name_key, default_account, strlen(default_account))) iDefaultEmailAccountId = accountId; |
97 |
126 |
98 } |
127 } |
100 } |
129 } |
101 |
130 |
102 QMessageAccountIdList TelepathyEngine::queryAccounts(const QMessageAccountFilter &filter, const QMessageAccountSortOrder &sortOrder, |
131 QMessageAccountIdList TelepathyEngine::queryAccounts(const QMessageAccountFilter &filter, const QMessageAccountSortOrder &sortOrder, |
103 uint limit, uint offset, bool &isFiltered, bool &isSorted) const |
132 uint limit, uint offset, bool &isFiltered, bool &isSorted) const |
104 { |
133 { |
|
134 // qDebug() << "TelepathyEngine::queryAccounts"; |
105 QMessageAccountIdList accountIds; |
135 QMessageAccountIdList accountIds; |
106 |
136 |
107 updateImAccounts(); |
137 updateImAccounts(); |
108 foreach (QMessageAccount value, iAccounts) { |
138 foreach (QMessageAccount value, iAccounts) { |
109 accountIds.append(value.id()); |
139 accountIds.append(value.id()); |