Merge lp:~karni/telegram-app/telegram-app-add-push into lp:telegram-app/app

Proposed by Michał Karnicki
Status: Merged
Merged at revision: 45
Proposed branch: lp:~karni/telegram-app/telegram-app-add-push
Merge into: lp:telegram-app/app
Diff against target: 172 lines (+53/-14)
8 files modified
CMakeLists.txt (+1/-1)
apparmor-push.json (+6/-0)
apparmor-telegram.json (+3/-2)
click.sh (+5/-1)
manifest.json.in (+7/-10)
push.json (+4/-0)
push.py (+7/-0)
telegram.qml (+20/-0)
To merge this branch: bzr merge lp:~karni/telegram-app/telegram-app-add-push
Reviewer Review Type Date Requested Status
Roberto Mier Escandon (community) Approve
Review via email: mp+233132@code.launchpad.net

Description of the change

Click package setup + QML setup for push.

getNotifications() is called in onWoken and onAuthLoggedIn to ensure we purge the pending notifications queue.

I suggest this API:

newNotifications.connect(telegramClient.onPushNotifications);
error.connect(telegramClient.onPushError);

Please log the QString in onPushError. You can (or not) log QStringList of onPushNotifications, but we'll probably need to disable it some time soon because of privacy.

To post a comment you must log in.
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

LGTM

review: Approve
51. By Michał Karnicki

Call unregister when logged out.

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

my fault, the methods are
accountRegisterDevice and accountUnregisterDevice. Sorry, I set it bad in comments

52. By Michał Karnicki

account, not accounts.

53. By Michał Karnicki

Fix click packaging.

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

LGTM

review: Approve
54. By Michał Karnicki

Fix package name in click.sh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-14 21:49:09 +0000
3+++ CMakeLists.txt 2014-09-03 09:58:33 +0000
4@@ -33,7 +33,7 @@
5 )
6
7 set(APP_NAME "telegram")
8-set(APP_PACKAGE "com.canonical.${APP_NAME}")
9+set(APP_PACKAGE "com.ubuntu.${APP_NAME}")
10 set(APP_TITLE "Telegram")
11 # Semantic versioning.
12 set(APP_VERSION "${VERSION_TAG}.${VERSION_REV}")
13
14=== added file 'apparmor-push.json'
15--- apparmor-push.json 1970-01-01 00:00:00 +0000
16+++ apparmor-push.json 2014-09-03 09:58:33 +0000
17@@ -0,0 +1,6 @@
18+{
19+ "policy_groups": [
20+ "push-notifications-client"
21+ ],
22+ "policy_version": 1.2
23+}
24
25=== renamed file 'apparmor.json' => 'apparmor-telegram.json'
26--- apparmor.json 2014-07-15 23:03:19 +0000
27+++ apparmor-telegram.json 2014-09-03 09:58:33 +0000
28@@ -1,6 +1,7 @@
29 {
30 "policy_groups": [
31- "networking"
32+ "networking",
33+ "push-notifications-client"
34 ],
35 "policy_version": 1.2
36-}
37\ No newline at end of file
38+}
39
40=== modified file 'click.sh'
41--- click.sh 2014-08-21 15:40:23 +0000
42+++ click.sh 2014-09-03 09:58:33 +0000
43@@ -19,7 +19,11 @@
44 cp -a build/$ARCH/library/lib/libqtelegram.so* click/lib/$ARCH_TRIPLET
45 cp -a build/$ARCH/library/qmlplugin/Telegram click/lib/$ARCH_TRIPLET
46
47-cp apparmor.json click/
48+cp apparmor-push.json click/
49+cp push.json click/
50+cp push.py click/
51+
52+cp apparmor-telegram.json click/
53 cp telegram.qml click/
54 cp telegram.pub click/
55
56
57=== modified file 'manifest.json.in'
58--- manifest.json.in 2014-08-23 00:15:59 +0000
59+++ manifest.json.in 2014-09-03 09:58:33 +0000
60@@ -6,18 +6,15 @@
61 "architecture": "@ARCHITECTURE@",
62 "title": "@APP_TITLE@",
63 "hooks": {
64- "@APP_NAME@": {
65- "apparmor": "apparmor.json",
66- "desktop": "@APP_NAME@.desktop"
67+ "telegram": {
68+ "apparmor": "apparmor-telegram.json",
69+ "desktop": "telegram.desktop"
70+ },
71+ "push": {
72+ "apparmor": "apparmor-push.json",
73+ "push-helper": "push.json"
74 }
75 },
76 "icon": "@APP_ICON@",
77 "maintainer": "https://launchpad.net/~libqtelegram-team",
78- "x-source": {
79- "vcs-bzr": "@BZR_SOURCE@",
80- "vcs-bzr-revno": "@BZR_REVNO@"
81- },
82- "x-test": {
83- "autopilot": "@AUTOPILOT_DIR@"
84- }
85 }
86
87=== added file 'push.json'
88--- push.json 1970-01-01 00:00:00 +0000
89+++ push.json 2014-09-03 09:58:33 +0000
90@@ -0,0 +1,4 @@
91+{
92+ "exec": "push.py",
93+ "app_id": "com.ubuntu.telegram_telegram"
94+}
95
96=== added file 'push.py'
97--- push.py 1970-01-01 00:00:00 +0000
98+++ push.py 2014-09-03 09:58:33 +0000
99@@ -0,0 +1,7 @@
100+#!/usr/bin/python3
101+
102+import sys
103+
104+f1, f2 = sys.argv[1:3]
105+open(f2, "w").write(open(f1).read())
106+
107
108=== modified file 'telegram.qml'
109--- telegram.qml 2014-09-02 14:30:36 +0000
110+++ telegram.qml 2014-09-03 09:58:33 +0000
111@@ -2,7 +2,9 @@
112 import QtMultimedia 5.0
113 import Qt.labs.settings 1.0
114 import Ubuntu.Components 1.1
115+import Ubuntu.PushNotifications 0.1
116 import Telegram 0.1
117+import "../js/version.js" as Version
118 import "ui"
119
120 MainView {
121@@ -29,6 +31,7 @@
122 if (initCalled) {
123 if (activeFocus) {
124 console.log("Telegram resuming..");
125+ pushClient.clearPersistent("chat");
126 telegramClient.wake();
127 } else {
128 console.log("Telegram suspending..");
129@@ -162,6 +165,17 @@
130 property double notificationVolume: 0.7
131 }
132
133+ PushClient {
134+ id: pushClient
135+ appId: "com.ubuntu.telegram_telegram"
136+ Component.onCompleted: {
137+ newNotifications.connect(telegramClient.onPushNotifications);
138+ error.connect(telegramClient.onPushError);
139+
140+ telegramClient.accountRegisterDevice(token, Version.version);
141+ }
142+ }
143+
144 TelegramClient {
145 id: telegramClient
146 configPath: "~/.config/" + applicationName
147@@ -230,6 +244,7 @@
148 }
149 pageStack.clear();
150 pageStack.push(dialogsPage);
151+ telegramClient.getNotifications();
152 }
153
154 onAuthLogOutAnswer: {
155@@ -237,12 +252,17 @@
156 sessionSettings.phoneNumber = "";
157 sessionSettings.isFirstLaunch = true;
158
159+ telegramClient.accountUnregisterDevice(pushClient.token);
160 pageStack.clear();
161 // TODO This line will go away when sign in page is used as component.
162 signInPage.enableForm();
163 pageStack.push(signInPage);
164 }
165
166+ onWoken: {
167+ telegramClient.getNotifications();
168+ }
169+
170 onUpdateShortMessage: {
171 //messageReceivedSound.play();
172 }

Subscribers

People subscribed via source and target branches