Merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by Eduardo Mucelli Rezende Oliveira
Status: Merged
Merged at revision: 226
Proposed branch: lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 136 lines (+47/-5)
4 files modified
Twitter/ChangeLog (+1/-0)
Twitter/Twitter (+43/-2)
Twitter/Twitter.conf (+1/-1)
Twitter/auto-load.conf (+2/-2)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Twitter
Reviewer Review Type Date Requested Status
Cairo-Dock Devs Pending
Review via email: mp+87869@code.launchpad.net

Description of the change

Received direct messages

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 'Twitter/ChangeLog'
2--- Twitter/ChangeLog 2011-12-17 00:14:56 +0000
3+++ Twitter/ChangeLog 2012-01-08 02:16:24 +0000
4@@ -1,1 +1,2 @@
5+0.0.2: (January/8/2012): Possible to see the received direct messages.
6 0.0.1: (December/16/2011): Possible to send a tweety, and see the home timeline.
7
8=== modified file 'Twitter/Twitter'
9--- Twitter/Twitter 2012-01-07 20:55:28 +0000
10+++ Twitter/Twitter 2012-01-08 02:16:24 +0000
11@@ -78,6 +78,7 @@
12 def __init__(self, access_key, access_secret):
13 self.update_url = 'http://twitter.com/statuses/update.json'
14 self.home_timeline_url = 'http://twitter.com/statuses/home_timeline.json'
15+ self.direct_messages_url = 'https://api.twitter.com/1/direct_messages.json'
16
17 self.signature_method = oauth.OAuthSignatureMethod_HMAC_SHA1()
18 consumer_key, consumer_secret = read_consumer_key_and_secret()
19@@ -161,6 +162,17 @@
20 response = get(url)
21 return simplejson.loads(response)
22
23+ def direct_messages(self):
24+ oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.consumer,
25+ token = self.access_token,
26+ http_url = self.direct_messages_url,
27+ http_method = "GET")
28+ oauth_request.sign_request(self.signature_method, self.consumer, self.access_token)
29+ url = oauth_request.to_url()
30+ response = get(url)
31+ print simplejson.loads(response)[0]
32+ return simplejson.loads(response)
33+
34 class User:
35 def __init__(self, screen_name="", access_key="", access_secret=""):
36 self.screen_name = screen_name
37@@ -179,13 +191,21 @@
38
39 def show_home_timeline(self):
40 self.inform_start_of_waiting_process()
41-
42 timeline = self.api.home_timeline()
43 if len(timeline) > 0:
44 message = "".join (["[%s] %s\n" % (status['user']['name'], status['text']) for status in timeline])
45 else:
46 message = "Oh, dear, your timeline is empty :-("
47+ self.inform_end_of_waiting_process()
48+ self.show_popup_message(message)
49
50+ def show_direct_messages(self):
51+ self.inform_start_of_waiting_process()
52+ messages = self.api.direct_messages()
53+ if len(messages) > 0:
54+ message = "".join (["[%s] %s\n" % (status['sender']['name'], status['text']) for status in messages])
55+ else:
56+ message = "Oh, dear, you do not have direct messages :-("
57 self.inform_end_of_waiting_process()
58 self.show_popup_message(message)
59
60@@ -266,14 +286,28 @@
61 widget_attributes.update(widget)
62 self.icon.PopupDialog (dialog_attributes, widget_attributes)
63
64+ def build_direct_messages_menu(self):
65+ direct_messages_menu = []
66+ direct_messages_menu.append ({
67+ 'type' : CDApplet.MENU_ENTRY,
68+ 'label' : "Received direct messages",
69+ 'menu' : CDApplet.MAIN_MENU_ID,
70+ 'id' : self.direct_messages_menu_id,
71+ 'icon' : os.path.abspath("./data/received.png")
72+ })
73+ self.icon.AddMenuItems(direct_messages_menu)
74+
75 def __init__(self):
76 self.user = User()
77 self.user_file = '.users'
78 self.twitter_auth = TwitterOauth()
79 self.api = None
80- self.responding_screen_name, self.responding_authorization, self.responding_pin, self.responding_success, self.responding_tweety, self.responding_initial_informations = range(6)
81+ (self.responding_screen_name, self.responding_authorization, self.responding_pin,
82+ self.responding_success, self.responding_tweety, self.responding_initial_informations) = range(6)
83 self.dialog_type = None
84
85+ self.direct_messages_menu_id = 1000
86+
87 CDApplet.__init__(self) # call CDApplet interface init
88
89 # Inherited methods from CDApplet
90@@ -322,5 +356,12 @@
91 def on_middle_click(self):
92 self.show_home_timeline()
93
94+ def on_build_menu(self):
95+ self.build_direct_messages_menu()
96+
97+ def on_menu_select(self, selected_menu):
98+ if selected_menu == self.direct_messages_menu_id:
99+ self.show_direct_messages()
100+
101 if __name__ == '__main__':
102 Applet().run()
103
104=== modified file 'Twitter/Twitter.conf'
105--- Twitter/Twitter.conf 2011-12-17 00:14:56 +0000
106+++ Twitter/Twitter.conf 2012-01-08 02:16:24 +0000
107@@ -1,4 +1,4 @@
108-#!en;0.0.1
109+#!en;0.0.2
110
111 #[gtk-about]
112 [Icon]
113
114=== modified file 'Twitter/auto-load.conf'
115--- Twitter/auto-load.conf 2011-12-18 02:15:50 +0000
116+++ Twitter/auto-load.conf 2012-01-08 02:16:24 +0000
117@@ -4,13 +4,13 @@
118 author = Eduardo Mucelli Rezende Oliveira
119
120 # A short description of the applet and how to use it.
121-description = On the first time, the applet is going to ask your nickname and authorization to connect with Twitter.\nThe applet is going to open your browser with the authorization page\nAs soon as you authorize it, a PIN number will be shown on the page, copy this number\nPaste this number on the next dialog box will be shown.\nThe plugin is going to inform that you are successfully connected.
122+description = You can send tweets, see your timeline, and the received directed messages.\nOn the first time, the applet is going to ask your nickname and authorization to connect with Twitter.\nThe applet is going to open your browser with the authorization page\nAs soon as you authorize it, a PIN number will be shown on the page, copy this number\nPaste this number on the next dialog box will be shown.\nThe plugin is going to inform that you are successfully connected.
123
124 # Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
125 category = 3
126
127 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
128-version = 0.0.1
129+version = 0.0.2
130
131 # Whether the applet can be instanciated several times or not.
132 multi-instance = true
133
134=== added directory 'Twitter/data'
135=== added file 'Twitter/data/received.png'
136Binary files Twitter/data/received.png 1970-01-01 00:00:00 +0000 and Twitter/data/received.png 2012-01-08 02:16:24 +0000 differ

Subscribers

People subscribed via source and target branches