Merge lp:~bfiller/telephony-service/rtm-14.09-sim-presence into lp:telephony-service/rtm-14.09

Proposed by Bill Filler
Status: Merged
Approved by: Bill Filler
Approved revision: 900
Merged at revision: 900
Proposed branch: lp:~bfiller/telephony-service/rtm-14.09-sim-presence
Merge into: lp:telephony-service/rtm-14.09
Diff against target: 243 lines (+81/-3)
4 files modified
libtelephonyservice/accountentry.cpp (+17/-0)
libtelephonyservice/accountentry.h (+3/-0)
libtelephonyservice/telepathyhelper.cpp (+51/-3)
libtelephonyservice/telepathyhelper.h (+10/-0)
To merge this branch: bzr merge lp:~bfiller/telephony-service/rtm-14.09-sim-presence
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+231914@code.launchpad.net

Commit message

sim presence and call grouping merge from trunk

Description of the change

sim presence and call grouping merge from trunk

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libtelephonyservice/accountentry.cpp'
2--- libtelephonyservice/accountentry.cpp 2014-08-11 23:51:35 +0000
3+++ libtelephonyservice/accountentry.cpp 2014-08-22 15:29:29 +0000
4@@ -48,6 +48,18 @@
5 return mAccount->displayName();
6 }
7
8+QString AccountEntry::networkName() const
9+{
10+ if (mAccount.isNull() || mAccount->connection().isNull() || mAccount->connection()->selfContact().isNull()) {
11+ return QString::null;
12+ }
13+ Tp::Presence presence = mAccount->connection()->selfContact()->presence();
14+ if (presence.type() == Tp::ConnectionPresenceTypeAvailable) {
15+ return mAccount->connection()->selfContact()->presence().statusMessage();
16+ }
17+ return QString::null;
18+}
19+
20 void AccountEntry::setDisplayName(const QString &name)
21 {
22 if (mAccount.isNull()) {
23@@ -139,6 +151,10 @@
24 connect(mAccount->connection()->selfContact().data(),
25 SIGNAL(presenceChanged(Tp::Presence)),
26 SIGNAL(connectedChanged()));
27+
28+ connect(mAccount->connection()->selfContact().data(),
29+ SIGNAL(presenceChanged(Tp::Presence)),
30+ SIGNAL(networkNameChanged()));
31 }
32
33 void AccountEntry::onConnectionChanged()
34@@ -186,6 +202,7 @@
35 watchSelfContactPresence();
36 }
37
38+ Q_EMIT networkNameChanged();
39 Q_EMIT connectedChanged();
40 }
41
42
43=== modified file 'libtelephonyservice/accountentry.h'
44--- libtelephonyservice/accountentry.h 2014-07-28 21:05:28 +0000
45+++ libtelephonyservice/accountentry.h 2014-08-22 15:29:29 +0000
46@@ -39,11 +39,13 @@
47 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
48 Q_PROPERTY(QStringList emergencyNumbers READ emergencyNumbers NOTIFY emergencyNumbersChanged)
49 Q_PROPERTY(QString voicemailNumber READ voicemailNumber NOTIFY voicemailNumberChanged)
50+ Q_PROPERTY(QString networkName READ networkName NOTIFY networkNameChanged)
51
52 public:
53 explicit AccountEntry(const Tp::AccountPtr &account, QObject *parent = 0);
54 QString accountId() const;
55 QString displayName() const;
56+ QString networkName() const;
57 void setDisplayName(const QString &name);
58 bool connected() const;
59 QStringList emergencyNumbers() const;
60@@ -54,6 +56,7 @@
61 void accountReady();
62 void accountIdChanged();
63 void displayNameChanged();
64+ void networkNameChanged();
65 void connectedChanged();
66 void emergencyNumbersChanged();
67 void voicemailNumberChanged();
68
69=== modified file 'libtelephonyservice/telepathyhelper.cpp'
70--- libtelephonyservice/telepathyhelper.cpp 2014-08-08 21:26:40 +0000
71+++ libtelephonyservice/telepathyhelper.cpp 2014-08-22 15:29:29 +0000
72@@ -43,7 +43,11 @@
73 mFirstTime(true),
74 mConnected(false),
75 mHandlerInterface(0),
76- mDefaultSimSettings(new QGSettings("com.ubuntu.phone"))
77+ mDefaultSimSettings(new QGSettings("com.ubuntu.phone")),
78+ mFlightModeInterface("org.freedesktop.URfkill",
79+ "/org/freedesktop/URfkill",
80+ "org.freedesktop.URfkill",
81+ QDBusConnection::systemBus())
82 {
83 mAccountFeatures << Tp::Account::FeatureCore;
84 mContactFeatures << Tp::Contact::FeatureAlias
85@@ -74,7 +78,7 @@
86 mClientRegistrar = Tp::ClientRegistrar::create(mAccountManager);
87 connect(this, SIGNAL(accountReady()), SIGNAL(setupReady()));
88 connect(mDefaultSimSettings, SIGNAL(changed(QString)), this, SLOT(onSettingsChanged(QString)));
89-
90+ connect(&mFlightModeInterface, SIGNAL(FlightModeChanged(bool)), this, SIGNAL(flightModeChanged()));
91 }
92
93 TelepathyHelper::~TelepathyHelper()
94@@ -107,16 +111,43 @@
95 return ids;
96 }
97
98+bool TelepathyHelper::flightMode()
99+{
100+ QDBusReply<bool> reply = mFlightModeInterface.call("IsFlightMode");
101+ if (reply.isValid()) {
102+ return reply;
103+ }
104+ return false;
105+}
106+
107 QList<AccountEntry*> TelepathyHelper::accounts() const
108 {
109 return mAccounts;
110 }
111
112+QList<AccountEntry*> TelepathyHelper::activeAccounts() const
113+{
114+ QList<AccountEntry*> activeAccountList;
115+ Q_FOREACH(AccountEntry *account, mAccounts) {
116+ if (!account->account()->connection().isNull() &&
117+ !account->account()->connection()->selfContact().isNull() &&
118+ account->account()->connection()->selfContact()->presence().type() != Tp::ConnectionPresenceTypeOffline) {
119+ activeAccountList << account;
120+ }
121+ }
122+ return activeAccountList;
123+}
124+
125 QQmlListProperty<AccountEntry> TelepathyHelper::qmlAccounts()
126 {
127 return QQmlListProperty<AccountEntry>(this, 0, accountsCount, accountAt);
128 }
129
130+QQmlListProperty<AccountEntry> TelepathyHelper::qmlActiveAccounts()
131+{
132+ return QQmlListProperty<AccountEntry>(this, 0, activeAccountsCount, activeAccountAt);
133+}
134+
135 ChannelObserver *TelepathyHelper::channelObserver() const
136 {
137 return mChannelObserver;
138@@ -281,20 +312,36 @@
139 return TelepathyHelper::instance()->accounts()[index];
140 }
141
142+int TelepathyHelper::activeAccountsCount(QQmlListProperty<AccountEntry> *p)
143+{
144+ return TelepathyHelper::instance()->activeAccounts().count();
145+}
146+
147+AccountEntry *TelepathyHelper::activeAccountAt(QQmlListProperty<AccountEntry> *p, int index)
148+{
149+ return TelepathyHelper::instance()->activeAccounts()[index];
150+}
151+
152 void TelepathyHelper::onAccountManagerReady(Tp::PendingOperation *op)
153 {
154 Q_UNUSED(op)
155
156 Tp::AccountSetPtr accountSet;
157+ QMap<QString, AccountEntry *> orderedAccounts;
158 // try to find an account of the one of supported protocols
159 Q_FOREACH(const QString &protocol, supportedProtocols()) {
160 accountSet = mAccountManager->accountsByProtocol(protocol);
161 Q_FOREACH(const Tp::AccountPtr &account, accountSet->accounts()) {
162+ QString modemObjName = account->parameters().value("modem-objpath").toString();
163 AccountEntry *accountEntry = new AccountEntry(account, this);
164+ connect(accountEntry,
165+ SIGNAL(connectedChanged()),
166+ SIGNAL(activeAccountsChanged()));
167 setupAccountEntry(accountEntry);
168- mAccounts << accountEntry;
169+ orderedAccounts[modemObjName] = accountEntry;
170 }
171 }
172+ mAccounts = orderedAccounts.values();
173
174 if (mAccounts.count() == 0) {
175 Q_EMIT setupReady();
176@@ -307,6 +354,7 @@
177
178 Q_EMIT accountIdsChanged();
179 Q_EMIT accountsChanged();
180+ Q_EMIT activeAccountsChanged();
181 onSettingsChanged("defaultSimForMessages");
182 onSettingsChanged("defaultSimForCalls");
183 }
184
185=== modified file 'libtelephonyservice/telepathyhelper.h'
186--- libtelephonyservice/telepathyhelper.h 2014-08-08 18:57:31 +0000
187+++ libtelephonyservice/telepathyhelper.h 2014-08-22 15:29:29 +0000
188@@ -46,8 +46,10 @@
189 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
190 Q_PROPERTY(QStringList accountIds READ accountIds NOTIFY accountIdsChanged)
191 Q_PROPERTY(QQmlListProperty<AccountEntry> accounts READ qmlAccounts NOTIFY accountsChanged)
192+ Q_PROPERTY(QQmlListProperty<AccountEntry> activeAccounts READ qmlActiveAccounts NOTIFY activeAccountsChanged)
193 Q_PROPERTY(AccountEntry *defaultMessagingAccount READ defaultMessagingAccount NOTIFY defaultMessagingAccountChanged)
194 Q_PROPERTY(AccountEntry *defaultCallAccount READ defaultCallAccount NOTIFY defaultCallAccountChanged)
195+ Q_PROPERTY(bool flightMode READ flightMode NOTIFY flightModeChanged)
196 Q_ENUMS(AccountType)
197 public:
198 enum AccountType {
199@@ -59,12 +61,15 @@
200
201 static TelepathyHelper *instance();
202 QList<AccountEntry*> accounts() const;
203+ QList<AccountEntry*> activeAccounts() const;
204 QQmlListProperty<AccountEntry> qmlAccounts();
205+ QQmlListProperty<AccountEntry> qmlActiveAccounts();
206 ChannelObserver *channelObserver() const;
207 QDBusInterface *handlerInterface() const;
208 AccountEntry *defaultMessagingAccount() const;
209 AccountEntry *defaultCallAccount() const;
210
211+ bool flightMode();
212 bool connected() const;
213 QStringList accountIds();
214 AccountEntry *accountForConnection(const Tp::ConnectionPtr &connection) const;
215@@ -79,6 +84,8 @@
216 // QQmlListProperty helpers
217 static int accountsCount(QQmlListProperty<AccountEntry> *p);
218 static AccountEntry *accountAt(QQmlListProperty<AccountEntry> *p, int index);
219+ static int activeAccountsCount(QQmlListProperty<AccountEntry> *p);
220+ static AccountEntry *activeAccountAt(QQmlListProperty<AccountEntry> *p, int index);
221
222 Q_SIGNALS:
223 void channelObserverCreated(ChannelObserver *observer);
224@@ -87,9 +94,11 @@
225 void connectedChanged();
226 void accountIdsChanged();
227 void accountsChanged();
228+ void activeAccountsChanged();
229 void setupReady();
230 void defaultMessagingAccountChanged();
231 void defaultCallAccountChanged();
232+ void flightModeChanged();
233
234 public Q_SLOTS:
235 Q_INVOKABLE void registerChannelObserver(const QString &observerName = QString::null);
236@@ -121,6 +130,7 @@
237 bool mConnected;
238 mutable QDBusInterface *mHandlerInterface;
239 QGSettings *mDefaultSimSettings;
240+ QDBusInterface mFlightModeInterface;
241 };
242
243 #endif // TELEPATHYHELPER_H

Subscribers

People subscribed via source and target branches