Merge lp:~samitheberber/openfilepad/gui-dev into lp:openfilepad
- gui-dev
- Merge into main
Proposed by
Sami Saada
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~samitheberber/openfilepad/gui-dev | ||||||||
Merge into: | lp:openfilepad | ||||||||
Diff against target: |
1147 lines 19 files modified
README (+5/-4) src/gfx/home.svg (+33/-0) src/gfx/logo.svg (+171/-0) src/gfx/mugshot_new.svg (+95/-0) src/gfx/mugshot_unknown.svg (+91/-0) src/gui/__init__.py (+2/-0) src/gui/friendtab.py (+15/-0) src/gui/hometab.py (+14/-0) src/gui/mainwindow.py (+18/-0) src/gui/newfriendtab.py (+111/-0) src/gui/userfiles.py (+34/-0) src/gui/userinfo.py (+90/-0) src/gui/userpicture.py (+59/-0) src/gui/usertab.py (+19/-0) src/gui/usertabwidget.py (+66/-0) src/guicontrol.py (+76/-0) src/qfriendslol.pyw (+31/-0) src/remote.py (+6/-7) src/store.py (+15/-14) |
||||||||
To merge this branch: | bzr merge lp:~samitheberber/openfilepad/gui-dev | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martti Rannanjärvi | Approve | ||
Review via email: mp+14053@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Sami Saada (samitheberber) wrote : | # |
Revision history for this message
Martti Rannanjärvi (mrannanj) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README' |
2 | --- README 2009-10-26 02:34:05 +0000 |
3 | +++ README 2009-10-27 21:15:19 +0000 |
4 | @@ -7,12 +7,13 @@ |
5 | |
6 | QFriendsLOL is a simple QT file drop box application that enables friends to exchange files by using OpenLookup v2. |
7 | |
8 | -To get QFriendsLOL running you need to get the latest OpenLookup. |
9 | -You can download it to your home directory by commanding: |
10 | - cd ~ |
11 | +QFriendsLOL requires simplejson and openlookup to run. Simplejson is probably |
12 | +packaged by your distribution. The name of the package is python-simplejson in |
13 | +Ubuntu and dev-python/simplejson in Gentoo. Openlookup you can download to your |
14 | +home directory with these commands: |
15 | + cd |
16 | svn checkout http://openlookup.googlecode.com/svn/v2 openlookup2 |
17 | |
18 | then set python path as follows before starting QFriendsLOL: |
19 | export PYTHONPATH=~/openlookup2 |
20 | |
21 | - |
22 | |
23 | === added directory 'src/gfx' |
24 | === added file 'src/gfx/home.svg' |
25 | --- src/gfx/home.svg 1970-01-01 00:00:00 +0000 |
26 | +++ src/gfx/home.svg 2009-10-27 21:15:19 +0000 |
27 | @@ -0,0 +1,33 @@ |
28 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
29 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
30 | +<svg |
31 | + xmlns:svg="http://www.w3.org/2000/svg" |
32 | + xmlns="http://www.w3.org/2000/svg" |
33 | + version="1.0" |
34 | + width="16" |
35 | + height="16" |
36 | + id="svg1901"> |
37 | + <defs |
38 | + id="defs1903" /> |
39 | + <g |
40 | + id="layer1" |
41 | + style="opacity:1"> |
42 | + <g |
43 | + transform="matrix(3.3802679e-2,0,0,3.9578024e-2,-3.7983281,-8.644124)" |
44 | + id="g2405"> |
45 | + <rect |
46 | + width="302.85715" |
47 | + height="211.42857" |
48 | + rx="0" |
49 | + ry="0" |
50 | + x="188.57143" |
51 | + y="375.21933" |
52 | + id="rect2380" |
53 | + style="fill:#000000;fill-opacity:1" /> |
54 | + <path |
55 | + d="M 340,252.36219 L 542.8571,378.07646 L 151.42857,378.07646 L 340,252.36219 z" |
56 | + id="rect2382" |
57 | + style="fill:#000000;fill-opacity:1" /> |
58 | + </g> |
59 | + </g> |
60 | +</svg> |
61 | |
62 | === added file 'src/gfx/logo.svg' |
63 | --- src/gfx/logo.svg 1970-01-01 00:00:00 +0000 |
64 | +++ src/gfx/logo.svg 2009-10-27 21:15:19 +0000 |
65 | @@ -0,0 +1,171 @@ |
66 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
67 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
68 | +<svg |
69 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
70 | + xmlns:cc="http://creativecommons.org/ns#" |
71 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
72 | + xmlns:svg="http://www.w3.org/2000/svg" |
73 | + xmlns="http://www.w3.org/2000/svg" |
74 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
75 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
76 | + version="1.0" |
77 | + width="53.300831" |
78 | + height="50.020782" |
79 | + id="svg1901" |
80 | + inkscape:version="0.46" |
81 | + sodipodi:docname="qfriendslol_logo.svg" |
82 | + sodipodi:version="0.32" |
83 | + inkscape:output_extension="org.inkscape.output.svg.inkscape"> |
84 | + <metadata |
85 | + id="metadata28"> |
86 | + <rdf:RDF> |
87 | + <cc:Work |
88 | + rdf:about=""> |
89 | + <dc:format>image/svg+xml</dc:format> |
90 | + <dc:type |
91 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
92 | + </cc:Work> |
93 | + </rdf:RDF> |
94 | + </metadata> |
95 | + <sodipodi:namedview |
96 | + pagecolor="#ffffff" |
97 | + bordercolor="#666666" |
98 | + borderopacity="1" |
99 | + objecttolerance="10" |
100 | + gridtolerance="10" |
101 | + guidetolerance="10" |
102 | + inkscape:pageopacity="0" |
103 | + inkscape:pageshadow="2" |
104 | + inkscape:window-width="789" |
105 | + inkscape:window-height="786" |
106 | + id="namedview26" |
107 | + showgrid="false" |
108 | + inkscape:zoom="5.3299604" |
109 | + inkscape:cx="55.118585" |
110 | + inkscape:cy="7.1743389" |
111 | + inkscape:window-x="0" |
112 | + inkscape:window-y="12" |
113 | + inkscape:window-maximized="0" |
114 | + inkscape:current-layer="g2899" /> |
115 | + <defs |
116 | + id="defs1903"> |
117 | + <inkscape:perspective |
118 | + sodipodi:type="inkscape:persp3d" |
119 | + inkscape:vp_x="0 : 372.04724 : 1" |
120 | + inkscape:vp_y="0 : 1000 : 0" |
121 | + inkscape:vp_z="1052.3622 : 372.04724 : 1" |
122 | + inkscape:persp3d-origin="526.18109 : 248.03149 : 1" |
123 | + id="perspective30" /> |
124 | + </defs> |
125 | + <g |
126 | + transform="matrix(0.7786856,0,0,0.7880085,-69.510459,-145.8237)" |
127 | + id="g2899"> |
128 | + <g |
129 | + id="g2974" |
130 | + transform="matrix(7.1574807e-2,0,0,7.1574807e-2,82.877173,171.80829)"> |
131 | + <g |
132 | + transform="matrix(1.2842154,0,0,1.2690218,896.81145,162.03984)" |
133 | + id="g2930"> |
134 | + <g |
135 | + id="g2561" |
136 | + transform="matrix(0.7121539,0,0,0.7121539,-652.62997,34.07993)"> |
137 | + <g |
138 | + style="fill:#729fcf" |
139 | + id="g2390"> |
140 | + <path |
141 | + style="fill:#729fcf" |
142 | + id="path2382" |
143 | + d="M 508.57143,223.79076 C 508.57143,342.1375 412.63244,438.07648 294.28571,438.07648 C 175.93897,438.07648 79.999985,342.1375 79.999985,223.79076 C 79.999985,105.44402 175.93897,9.5050375 294.28571,9.5050375 C 412.63244,9.5050375 508.57143,105.44402 508.57143,223.79076 L 508.57143,223.79076 z" /> |
144 | + <rect |
145 | + style="fill:#729fcf" |
146 | + id="rect2384" |
147 | + y="419.50504" |
148 | + x="33.428574" |
149 | + ry="120" |
150 | + rx="174.28572" |
151 | + height="474.28574" |
152 | + width="522.85712" /> |
153 | + </g> |
154 | + </g> |
155 | + <g |
156 | + style="fill:#ef2929" |
157 | + id="g2566" |
158 | + transform="matrix(0.7121539,0,0,0.7121539,-280.2977,34.066399)"> |
159 | + <g |
160 | + style="fill:#ef2929" |
161 | + id="g2568"> |
162 | + <path |
163 | + style="fill:#ef2929" |
164 | + id="path2570" |
165 | + d="M 508.57143,223.79076 C 508.57143,342.1375 412.63244,438.07648 294.28571,438.07648 C 175.93897,438.07648 79.999985,342.1375 79.999985,223.79076 C 79.999985,105.44402 175.93897,9.5050375 294.28571,9.5050375 C 412.63244,9.5050375 508.57143,105.44402 508.57143,223.79076 L 508.57143,223.79076 z" /> |
166 | + <rect |
167 | + style="fill:#ef2929" |
168 | + id="rect2572" |
169 | + y="419.50504" |
170 | + x="33.428574" |
171 | + ry="120" |
172 | + rx="174.28572" |
173 | + height="474.28574" |
174 | + width="522.85712" /> |
175 | + </g> |
176 | + </g> |
177 | + </g> |
178 | + <g |
179 | + id="g2952"> |
180 | + <g |
181 | + style="fill:#8ae234" |
182 | + id="g2574" |
183 | + transform="matrix(1.0149288,0,0,1.0029211,272.88051,175.52064)"> |
184 | + <g |
185 | + style="fill:#8ae234" |
186 | + id="g2576"> |
187 | + <path |
188 | + style="fill:#8ae234" |
189 | + id="path2578" |
190 | + d="M 508.57143,223.79076 C 508.57143,342.1375 412.63244,438.07648 294.28571,438.07648 C 175.93897,438.07648 79.999985,342.1375 79.999985,223.79076 C 79.999985,105.44402 175.93897,9.5050375 294.28571,9.5050375 C 412.63244,9.5050375 508.57143,105.44402 508.57143,223.79076 L 508.57143,223.79076 z" /> |
191 | + <rect |
192 | + style="fill:#8ae234" |
193 | + id="rect2580" |
194 | + y="419.50504" |
195 | + x="33.428574" |
196 | + ry="120" |
197 | + rx="174.28572" |
198 | + height="474.28574" |
199 | + width="522.85712" /> |
200 | + </g> |
201 | + </g> |
202 | + <text |
203 | + x="444.51709" |
204 | + y="516.66309" |
205 | + id="text3360" |
206 | + xml:space="preserve" |
207 | + style="font-size:323.3861084px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"><tspan |
208 | + x="444.51709" |
209 | + y="516.66309" |
210 | + id="tspan3362">Q</tspan></text> |
211 | + <g |
212 | + id="g2877" |
213 | + transform="matrix(1.0216867,0,0,1.0216867,166.7808,-619.91001)"> |
214 | + <text |
215 | + style="font-size:237.41375732px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" |
216 | + xml:space="preserve" |
217 | + id="text3364" |
218 | + y="1561.1241" |
219 | + x="165.02359"><tspan |
220 | + id="tspan3366" |
221 | + y="1561.1241" |
222 | + x="165.02359">LOL</tspan></text> |
223 | + <text |
224 | + style="font-size:99.64174652px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" |
225 | + xml:space="preserve" |
226 | + id="text3368" |
227 | + y="1359.7706" |
228 | + x="178.23366"><tspan |
229 | + id="tspan3370" |
230 | + y="1359.7706" |
231 | + x="178.23366">FRIENDS</tspan></text> |
232 | + </g> |
233 | + </g> |
234 | + </g> |
235 | + </g> |
236 | +</svg> |
237 | |
238 | === added file 'src/gfx/mugshot_new.svg' |
239 | --- src/gfx/mugshot_new.svg 1970-01-01 00:00:00 +0000 |
240 | +++ src/gfx/mugshot_new.svg 2009-10-27 21:15:19 +0000 |
241 | @@ -0,0 +1,95 @@ |
242 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
243 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
244 | +<svg |
245 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
246 | + xmlns:cc="http://creativecommons.org/ns#" |
247 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
248 | + xmlns:svg="http://www.w3.org/2000/svg" |
249 | + xmlns="http://www.w3.org/2000/svg" |
250 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
251 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
252 | + version="1.0" |
253 | + width="57.575825" |
254 | + height="97.375511" |
255 | + id="svg1901" |
256 | + sodipodi:version="0.32" |
257 | + inkscape:version="0.46" |
258 | + sodipodi:docname="mugshot_new.svg" |
259 | + inkscape:output_extension="org.inkscape.output.svg.inkscape"> |
260 | + <metadata |
261 | + id="metadata2424"> |
262 | + <rdf:RDF> |
263 | + <cc:Work |
264 | + rdf:about=""> |
265 | + <dc:format>image/svg+xml</dc:format> |
266 | + <dc:type |
267 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
268 | + </cc:Work> |
269 | + </rdf:RDF> |
270 | + </metadata> |
271 | + <sodipodi:namedview |
272 | + inkscape:window-height="1022" |
273 | + inkscape:window-width="789" |
274 | + inkscape:pageshadow="2" |
275 | + inkscape:pageopacity="0.0" |
276 | + guidetolerance="10.0" |
277 | + gridtolerance="10.0" |
278 | + objecttolerance="10.0" |
279 | + borderopacity="1.0" |
280 | + bordercolor="#666666" |
281 | + pagecolor="#ffffff" |
282 | + id="base" |
283 | + showgrid="false" |
284 | + inkscape:zoom="1.8928844" |
285 | + inkscape:cx="115.61036" |
286 | + inkscape:cy="39.417556" |
287 | + inkscape:window-x="0" |
288 | + inkscape:window-y="0" |
289 | + inkscape:current-layer="svg1901" /> |
290 | + <defs |
291 | + id="defs1903"> |
292 | + <inkscape:perspective |
293 | + sodipodi:type="inkscape:persp3d" |
294 | + inkscape:vp_x="0 : 526.18109 : 1" |
295 | + inkscape:vp_y="0 : 1000 : 0" |
296 | + inkscape:vp_z="744.09448 : 526.18109 : 1" |
297 | + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" |
298 | + id="perspective2426" /> |
299 | + </defs> |
300 | + <g |
301 | + id="layer1" |
302 | + style="opacity:1" |
303 | + transform="matrix(0.1101177,0,0,0.1101177,-13.056815,-7.4177671)"> |
304 | + <g |
305 | + transform="translate(85.14287,57.857131)" |
306 | + id="g2433" |
307 | + style="opacity:1"> |
308 | + <g |
309 | + id="g2390" |
310 | + style="fill:#729fcf"> |
311 | + <path |
312 | + d="M 508.57143,223.79076 C 508.57143,342.1375 412.63244,438.07648 294.28571,438.07648 C 175.93897,438.07648 79.999985,342.1375 79.999985,223.79076 C 79.999985,105.44402 175.93897,9.5050375 294.28571,9.5050375 C 412.63244,9.5050375 508.57143,105.44402 508.57143,223.79076 L 508.57143,223.79076 z" |
313 | + id="path2382" |
314 | + style="fill:#729fcf" /> |
315 | + <rect |
316 | + width="522.85712" |
317 | + height="474.28574" |
318 | + rx="174.28572" |
319 | + ry="120" |
320 | + x="33.428574" |
321 | + y="419.50504" |
322 | + id="rect2384" |
323 | + style="fill:#729fcf" /> |
324 | + </g> |
325 | + </g> |
326 | + <text |
327 | + x="71.970245" |
328 | + y="942.89124" |
329 | + id="text2438" |
330 | + xml:space="preserve" |
331 | + style="font-size:731.74212646px;font-style:normal;font-weight:normal;fill:#204a87;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"><tspan |
332 | + x="71.970245" |
333 | + y="942.89124" |
334 | + id="tspan2440">+</tspan></text> |
335 | + </g> |
336 | +</svg> |
337 | |
338 | === added file 'src/gfx/mugshot_unknown.svg' |
339 | --- src/gfx/mugshot_unknown.svg 1970-01-01 00:00:00 +0000 |
340 | +++ src/gfx/mugshot_unknown.svg 2009-10-27 21:15:19 +0000 |
341 | @@ -0,0 +1,91 @@ |
342 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
343 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
344 | +<svg |
345 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
346 | + xmlns:cc="http://creativecommons.org/ns#" |
347 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
348 | + xmlns:svg="http://www.w3.org/2000/svg" |
349 | + xmlns="http://www.w3.org/2000/svg" |
350 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
351 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
352 | + version="1.0" |
353 | + width="49.8494" |
354 | + height="84.308144" |
355 | + id="svg1901" |
356 | + sodipodi:version="0.32" |
357 | + inkscape:version="0.46" |
358 | + sodipodi:docname="mugshot_unknown.svg" |
359 | + inkscape:output_extension="org.inkscape.output.svg.inkscape"> |
360 | + <metadata |
361 | + id="metadata2540"> |
362 | + <rdf:RDF> |
363 | + <cc:Work |
364 | + rdf:about=""> |
365 | + <dc:format>image/svg+xml</dc:format> |
366 | + <dc:type |
367 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
368 | + </cc:Work> |
369 | + </rdf:RDF> |
370 | + </metadata> |
371 | + <sodipodi:namedview |
372 | + inkscape:window-height="510" |
373 | + inkscape:window-width="487" |
374 | + inkscape:pageshadow="2" |
375 | + inkscape:pageopacity="0.0" |
376 | + guidetolerance="10.0" |
377 | + gridtolerance="10.0" |
378 | + objecttolerance="10.0" |
379 | + borderopacity="1.0" |
380 | + bordercolor="#666666" |
381 | + pagecolor="#ffffff" |
382 | + id="base" |
383 | + showgrid="false" |
384 | + inkscape:zoom="2.6769428" |
385 | + inkscape:cx="36.591392" |
386 | + inkscape:cy="21.560543" |
387 | + inkscape:window-x="791" |
388 | + inkscape:window-y="0" |
389 | + inkscape:current-layer="svg1901" /> |
390 | + <defs |
391 | + id="defs1903"> |
392 | + <inkscape:perspective |
393 | + sodipodi:type="inkscape:persp3d" |
394 | + inkscape:vp_x="0 : 526.18109 : 1" |
395 | + inkscape:vp_y="0 : 1000 : 0" |
396 | + inkscape:vp_z="744.09448 : 526.18109 : 1" |
397 | + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" |
398 | + id="perspective2542" /> |
399 | + </defs> |
400 | + <g |
401 | + id="layer1" |
402 | + style="opacity:1" |
403 | + transform="matrix(9.5340385e-2,0,0,9.5340385e-2,-3.1870931,-0.9062139)"> |
404 | + <g |
405 | + id="g2390" |
406 | + style="fill:#729fcf"> |
407 | + <path |
408 | + d="M 508.57143,223.79076 C 508.57143,342.1375 412.63244,438.07648 294.28571,438.07648 C 175.93897,438.07648 79.999985,342.1375 79.999985,223.79076 C 79.999985,105.44402 175.93897,9.5050375 294.28571,9.5050375 C 412.63244,9.5050375 508.57143,105.44402 508.57143,223.79076 L 508.57143,223.79076 z" |
409 | + id="path2382" |
410 | + style="fill:#729fcf" /> |
411 | + <rect |
412 | + width="522.85712" |
413 | + height="474.28574" |
414 | + rx="174.28572" |
415 | + ry="120" |
416 | + x="33.428574" |
417 | + y="419.50504" |
418 | + id="rect2384" |
419 | + style="fill:#729fcf" /> |
420 | + </g> |
421 | + <text |
422 | + x="159.92941" |
423 | + y="632.41937" |
424 | + transform="scale(0.8084629,1.2369151)" |
425 | + id="text2386" |
426 | + xml:space="preserve" |
427 | + style="font-size:778.21777344px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#204a87;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Rudelsberg;-inkscape-font-specification:Rudelsberg Medium"><tspan |
428 | + x="159.92941" |
429 | + y="632.41937" |
430 | + id="tspan2388">?</tspan></text> |
431 | + </g> |
432 | +</svg> |
433 | |
434 | === added directory 'src/gui' |
435 | === added file 'src/gui/__init__.py' |
436 | --- src/gui/__init__.py 1970-01-01 00:00:00 +0000 |
437 | +++ src/gui/__init__.py 2009-10-27 21:15:19 +0000 |
438 | @@ -0,0 +1,2 @@ |
439 | +#!/usr/bin/python2.6 |
440 | +# -*- coding: utf-8 -*- |
441 | |
442 | === added file 'src/gui/friendtab.py' |
443 | --- src/gui/friendtab.py 1970-01-01 00:00:00 +0000 |
444 | +++ src/gui/friendtab.py 2009-10-27 21:15:19 +0000 |
445 | @@ -0,0 +1,15 @@ |
446 | +#!/usr/bin/python2.6 |
447 | +# -*- coding: utf-8 -*- |
448 | + |
449 | +from userfiles import UserFiles |
450 | +from userinfo import UserInfo |
451 | +from usertab import UserTab |
452 | + |
453 | + |
454 | +class FriendTab(UserTab): |
455 | + |
456 | + def __init__(self, control, friendId, *args): |
457 | + apply(UserTab.__init__, (self, control, ) + args) |
458 | + self._friendId = friendId |
459 | + self.addWidget(UserInfo(control, self._friendId)) |
460 | + self.addWidget(UserFiles(control, self._friendId)) |
461 | |
462 | === added file 'src/gui/hometab.py' |
463 | --- src/gui/hometab.py 1970-01-01 00:00:00 +0000 |
464 | +++ src/gui/hometab.py 2009-10-27 21:15:19 +0000 |
465 | @@ -0,0 +1,14 @@ |
466 | +#!/usr/bin/python2.6 |
467 | +# -*- coding: utf-8 -*- |
468 | + |
469 | +from userfiles import UserFiles |
470 | +from userinfo import UserInfo |
471 | +from usertab import UserTab |
472 | + |
473 | + |
474 | +class HomeTab(UserTab): |
475 | + |
476 | + def __init__(self, control, *args): |
477 | + apply(UserTab.__init__, (self, control, ) + args) |
478 | + self.addWidget(UserInfo(control)) |
479 | + self.addWidget(UserFiles(control)) |
480 | |
481 | === added file 'src/gui/mainwindow.py' |
482 | --- src/gui/mainwindow.py 1970-01-01 00:00:00 +0000 |
483 | +++ src/gui/mainwindow.py 2009-10-27 21:15:19 +0000 |
484 | @@ -0,0 +1,18 @@ |
485 | +#!/usr/bin/python2.6 |
486 | +# -*- coding: utf-8 -*- |
487 | + |
488 | +from usertabwidget import UserTabWidget |
489 | + |
490 | +from PyQt4.QtGui import QIcon |
491 | +from PyQt4.QtGui import QMainWindow |
492 | + |
493 | + |
494 | +class MainWindow(QMainWindow): |
495 | + |
496 | + def __init__(self, control, *args): |
497 | + apply(QMainWindow.__init__, (self, ) + args) |
498 | + self.setWindowTitle(u'QFriendsLOL') |
499 | + self._control = control |
500 | + self.setWindowIcon(QIcon(self._control.getGFXPath() + '/logo.svg')) |
501 | + self._userTabs = UserTabWidget(control) |
502 | + self.setCentralWidget(self._userTabs) |
503 | |
504 | === added file 'src/gui/newfriendtab.py' |
505 | --- src/gui/newfriendtab.py 1970-01-01 00:00:00 +0000 |
506 | +++ src/gui/newfriendtab.py 2009-10-27 21:15:19 +0000 |
507 | @@ -0,0 +1,111 @@ |
508 | +#!/usr/bin/python2.6 |
509 | +# -*- coding: utf-8 -*- |
510 | + |
511 | +from usertab import UserTab |
512 | + |
513 | +from PyQt4.QtGui import QLabel |
514 | +from PyQt4.QtGui import QWidget |
515 | +from PyQt4.QtGui import QHBoxLayout |
516 | +from PyQt4.QtGui import QVBoxLayout |
517 | +from PyQt4.QtGui import QPixmap |
518 | +from PyQt4.QtGui import QLineEdit |
519 | +from PyQt4.QtGui import QPushButton |
520 | +from PyQt4.QtGui import QScrollArea |
521 | +from PyQt4.QtCore import Qt |
522 | +from PyQt4.QtCore import QObject |
523 | +from PyQt4.QtCore import SIGNAL |
524 | +from PyQt4.QtCore import SLOT |
525 | + |
526 | + |
527 | +class NewFriendTab(UserTab): |
528 | + |
529 | + def __init__(self, control, *args): |
530 | + apply(UserTab.__init__, (self, control, ) + args) |
531 | + self._searchBox() |
532 | + self._searchResults() |
533 | + |
534 | + def _searchBox(self): |
535 | + searchBoxWidget = QWidget() |
536 | + self.addWidget(searchBoxWidget) |
537 | + searchBoxLayout = QHBoxLayout() |
538 | + searchBoxWidget.setLayout(searchBoxLayout) |
539 | + |
540 | + searchBoxLayout.addWidget(self._searchBoxPicture()) |
541 | + searchBoxLayout.addWidget(self._searchBoxDataField()) |
542 | + searchBoxLayout.addWidget(self._searchBoxSubmit()) |
543 | + |
544 | + QObject.connect(self._addButton, SIGNAL('pressed()'), self._searchUser) |
545 | + QObject.connect(self._searchField, SIGNAL('returnPressed()'), self._searchUser) |
546 | + |
547 | + def _searchBoxPicture(self): |
548 | + picture = QLabel() |
549 | + picture.setPixmap(QPixmap(self._control.getGFXPath() + '/mugshot_new.svg')) |
550 | + return picture |
551 | + |
552 | + def _searchBoxDataField(self): |
553 | + self._searchField = QLineEdit() |
554 | + self._errorMessage = QLabel() |
555 | + self._errorMessage.hide() |
556 | + |
557 | + searchData = QWidget() |
558 | + searchLayout = QVBoxLayout() |
559 | + searchLayout.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop); |
560 | + searchData.setLayout(searchLayout) |
561 | + |
562 | + searchLayout.addWidget(QLabel(u'Enter email or user id:')) |
563 | + searchLayout.addWidget(self._searchField) |
564 | + searchLayout.addWidget(self._errorMessage) |
565 | + return searchData |
566 | + |
567 | + def _searchBoxSubmit(self): |
568 | + self._addButton = QPushButton(u'Add') |
569 | + self._addButton.setAutoDefault(True) |
570 | + self._addButton.setDefault(True) |
571 | + return self._addButton |
572 | + |
573 | + def _searchResults(self): |
574 | + self._results = QScrollArea() |
575 | + self.addWidget(self._results) |
576 | + |
577 | + def _searchUser(self): |
578 | + searchData = str(self._searchField.text()) |
579 | + hits = [uid for uid in self._control.getRemote().findUser(searchData) \ |
580 | + if not uid == self._control.getRemote().localIdentityHex()] |
581 | + |
582 | + old = self._results.widget() |
583 | + if old: |
584 | + old.destroy() |
585 | + self._results.setWidget(QWidget()) |
586 | + |
587 | + if len(hits) == 0: |
588 | + self._errorMessage.setText(u'No such user.') |
589 | + self._errorMessage.show() |
590 | + elif len(hits) > 1: |
591 | + self._errorMessage.setText(u'Many hits from such user.') |
592 | + self._errorMessage.show() |
593 | + self._addToSearchResults(hits) |
594 | + else: |
595 | + hit = hits[0] |
596 | + if hit in self._control.getStore().getFriends(): |
597 | + self._errorMessage.setText(u'Found user is already in your friends.') |
598 | + self._errorMessage.show() |
599 | + else: |
600 | + self._searchField.setText(u'') |
601 | + self._errorMessage.setText(u'') |
602 | + self._errorMessage.hide() |
603 | + if not self._control.getRemote().isValidId(searchData): |
604 | + self._control.addUser(hit, searchData) |
605 | + else: |
606 | + self._control.addUser(hit) |
607 | + |
608 | + def _addToSearchResults(self, hits): |
609 | + results = QWidget() |
610 | + resultsLayout = QVBoxLayout() |
611 | + results.setLayout(resultsLayout) |
612 | + for hit in hits: |
613 | + resultsLayout.addWidget(self._morphHit(hit)) |
614 | + self._results.setWidget(results) |
615 | + |
616 | + def _morphHit(self, hit): |
617 | + #TODO: Add better view. |
618 | + return QLabel(u'%s' % hit) |
619 | |
620 | === added file 'src/gui/userfiles.py' |
621 | --- src/gui/userfiles.py 1970-01-01 00:00:00 +0000 |
622 | +++ src/gui/userfiles.py 2009-10-27 21:15:19 +0000 |
623 | @@ -0,0 +1,34 @@ |
624 | +#!/usr/bin/python2.6 |
625 | +# -*- coding: utf-8 -*- |
626 | + |
627 | +from PyQt4.QtGui import QLabel |
628 | +from PyQt4.QtGui import QScrollArea |
629 | +from PyQt4.QtGui import QVBoxLayout |
630 | +from PyQt4.QtCore import Qt |
631 | + |
632 | + |
633 | +class UserFiles(QScrollArea): |
634 | + |
635 | + def __init__(self, control, userId = None, *args): |
636 | + apply(QScrollArea.__init__, (self, ) + args) |
637 | + |
638 | + self._control = control |
639 | + self._userId = self._control.getRemote().localIdentityHex() \ |
640 | + if userId == None else userId |
641 | + |
642 | + self._layout = QVBoxLayout() |
643 | + self.setLayout(self._layout) |
644 | + |
645 | + self.update() |
646 | + |
647 | + def update(self): |
648 | + files = self._control.getRemote().getfilenames(self._userId) |
649 | + if files: |
650 | + for file in files: |
651 | + fileLabel = QLabel(u'%s' % file) |
652 | + fileLabel.setAlignment(Qt.AlignLeft|Qt.AlignTop) |
653 | + self._layout.addWidget(fileLabel) |
654 | + else: |
655 | + notFoundLabel = QLabel(u'No files found.') |
656 | + notFoundLabel.setAlignment(Qt.AlignHCenter|Qt.AlignTop) |
657 | + self._layout.addWidget(notFoundLabel) |
658 | |
659 | === added file 'src/gui/userinfo.py' |
660 | --- src/gui/userinfo.py 1970-01-01 00:00:00 +0000 |
661 | +++ src/gui/userinfo.py 2009-10-27 21:15:19 +0000 |
662 | @@ -0,0 +1,90 @@ |
663 | +#!/usr/bin/python2.6 |
664 | +# -*- coding: utf-8 -*- |
665 | + |
666 | +from userpicture import UserPicture |
667 | + |
668 | +from PyQt4.QtGui import QHBoxLayout |
669 | +from PyQt4.QtGui import QLabel |
670 | +from PyQt4.QtGui import QLineEdit |
671 | +from PyQt4.QtGui import QPushButton |
672 | +from PyQt4.QtGui import QVBoxLayout |
673 | +from PyQt4.QtGui import QWidget |
674 | +from PyQt4.QtCore import Qt |
675 | +from PyQt4.QtCore import QObject |
676 | +from PyQt4.QtCore import SIGNAL |
677 | +from PyQt4.QtCore import SLOT |
678 | + |
679 | + |
680 | +class UserInfo(QWidget): |
681 | + |
682 | + def __init__(self, control, userId = None, *args): |
683 | + apply(QWidget.__init__, (self, ) + args) |
684 | + self._control = control |
685 | + self._layout = QHBoxLayout() |
686 | + self._layout.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop); |
687 | + self.setLayout(self._layout) |
688 | + self._email = None |
689 | + self._layout.addWidget(UserPicture(self._control, userId)) |
690 | + if userId: |
691 | + self._friendHeader(userId) |
692 | + else: |
693 | + self._userHeader() |
694 | + self._uid = userId |
695 | + |
696 | + def _userHeader(self): |
697 | + emailData = self._control.getStore().getEmail() |
698 | + if not emailData: |
699 | + emailData = '' |
700 | + self._email = QLineEdit(u'%s' % emailData) |
701 | + QObject.connect(self._email, SIGNAL('returnPressed()'), self._changeEmail) |
702 | + |
703 | + data = QWidget() |
704 | + dataLayout = QVBoxLayout() |
705 | + dataLayout.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop); |
706 | + data.setLayout(dataLayout) |
707 | + |
708 | + userId = QLabel(u'User id: %s' % self._control.getRemote().localIdentityHex()) |
709 | + userId.setTextInteractionFlags(Qt.TextSelectableByMouse) |
710 | + dataLayout.addWidget(userId) |
711 | + |
712 | + email = QWidget() |
713 | + emailLayout = QHBoxLayout() |
714 | + email.setLayout(emailLayout) |
715 | + emailLayout.addWidget(QLabel(u'Email:')) |
716 | + emailLayout.addWidget(self._email) |
717 | + dataLayout.addWidget(email) |
718 | + |
719 | + self._layout.addWidget(data) |
720 | + |
721 | + def _friendHeader(self, friendId): |
722 | + data = QWidget() |
723 | + |
724 | + dataLayout = QVBoxLayout() |
725 | + dataLayout.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop); |
726 | + |
727 | + userId = QLabel(u'User id: %s' % friendId) |
728 | + userId.setTextInteractionFlags(Qt.TextSelectableByMouse) |
729 | + dataLayout.addWidget(userId) |
730 | + |
731 | + emailData = self._control.getStore().getEmail(friendId) |
732 | + if emailData: |
733 | + email = QLabel(u'Email: %s' % emailData) |
734 | + email.setTextInteractionFlags(Qt.TextSelectableByMouse) |
735 | + dataLayout.addWidget(email) |
736 | + |
737 | + data.setLayout(dataLayout) |
738 | + self._layout.addWidget(data) |
739 | + |
740 | + actionButton = QPushButton(u'Forget') |
741 | + QObject.connect(actionButton, SIGNAL('pressed()'), self._forgetUser) |
742 | + self._layout.addWidget(actionButton) |
743 | + |
744 | + def _forgetUser(self): |
745 | + self._control.forgetUser(self._uid) |
746 | + |
747 | + def _changeEmail(self): |
748 | + self._control.changeEmail(str(self._email.text())) |
749 | + |
750 | + def _changeMugshot(self): |
751 | + #self._control.changeMugshot(str(self._email.text())) |
752 | + pass |
753 | |
754 | === added file 'src/gui/userpicture.py' |
755 | --- src/gui/userpicture.py 1970-01-01 00:00:00 +0000 |
756 | +++ src/gui/userpicture.py 2009-10-27 21:15:19 +0000 |
757 | @@ -0,0 +1,59 @@ |
758 | +#!/usr/bin/python2.6 |
759 | +# -*- coding: utf-8 -*- |
760 | + |
761 | +from PyQt4.QtGui import QHBoxLayout |
762 | +from PyQt4.QtGui import QImage |
763 | +from PyQt4.QtGui import QPushButton |
764 | +from PyQt4.QtGui import QPixmap |
765 | +from PyQt4.QtGui import QIcon |
766 | +from PyQt4.QtGui import QFileDialog |
767 | +from PyQt4.QtCore import Qt |
768 | +from PyQt4.QtCore import QSize |
769 | +from PyQt4.QtCore import QObject |
770 | +from PyQt4.QtCore import SIGNAL |
771 | +from PyQt4.QtCore import SLOT |
772 | + |
773 | + |
774 | +class UserPicture(QPushButton): |
775 | + |
776 | + def __init__(self, control, userId = None, *args): |
777 | + apply(QPushButton.__init__, (self, ) + args) |
778 | + self._control = control |
779 | + self._userId = userId |
780 | + self.setIconSize(QSize(100, 100)) |
781 | + self.setFlat(True) |
782 | + self.update() |
783 | + if userId: |
784 | + QObject.connect(self, SIGNAL('pressed()'), self._pictureUpdate) |
785 | + else: |
786 | + QObject.connect(self, SIGNAL('pressed()'), self._pictureChange) |
787 | + |
788 | + def update(self): |
789 | + mugshot = self._control.getStore().getMugshot(self._userId) |
790 | + if mugshot: |
791 | + mugData = QPixmap() |
792 | + mugData.loadFromData(mugshot) |
793 | + pictureData = mugData.scaled(100,100, Qt.KeepAspectRatio) |
794 | + else: |
795 | + pictureData = QPixmap(self._control.getGFXPath() + '/mugshot_unknown.svg') |
796 | + self.setIcon(QIcon(pictureData)) |
797 | + |
798 | + def _pictureChange(self): |
799 | + filePath = QFileDialog.getOpenFileName(None, u'Open Image', '', 'Image Files (*.png *.jpg *.bmp *.svg)'); |
800 | + import os.path |
801 | + if os.path.isfile(filePath): |
802 | + file = open(filePath, 'r') |
803 | + data = file.read() |
804 | + file.close() |
805 | + self._control.changeMugshot(data) |
806 | + self.update() |
807 | + |
808 | + def _pictureUpdate(self): |
809 | + try: |
810 | + mugshot = self._control.getRemote().retrieve('mugshot', self._userId) |
811 | + except: |
812 | + mugshot = None |
813 | + if mugshot: |
814 | + self._control.getStore().putMugshot(mugshot, self._userId) |
815 | + self.update() |
816 | + self._control.refreshTab(self._userId) |
817 | |
818 | === added file 'src/gui/usertab.py' |
819 | --- src/gui/usertab.py 1970-01-01 00:00:00 +0000 |
820 | +++ src/gui/usertab.py 2009-10-27 21:15:19 +0000 |
821 | @@ -0,0 +1,19 @@ |
822 | +#!/usr/bin/python2.6 |
823 | +# -*- coding: utf-8 -*- |
824 | + |
825 | +from PyQt4.QtGui import QWidget |
826 | +from PyQt4.QtGui import QVBoxLayout |
827 | +from PyQt4.QtCore import Qt |
828 | + |
829 | + |
830 | +class UserTab(QWidget): |
831 | + |
832 | + def __init__(self, control, *args): |
833 | + apply(QWidget.__init__, (self, ) + args) |
834 | + self._control = control |
835 | + self._layout = QVBoxLayout() |
836 | + self._layout.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop); |
837 | + self.setLayout(self._layout) |
838 | + |
839 | + def addWidget(self, widget): |
840 | + self._layout.addWidget(widget) |
841 | |
842 | === added file 'src/gui/usertabwidget.py' |
843 | --- src/gui/usertabwidget.py 1970-01-01 00:00:00 +0000 |
844 | +++ src/gui/usertabwidget.py 2009-10-27 21:15:19 +0000 |
845 | @@ -0,0 +1,66 @@ |
846 | +#!/usr/bin/python2.6 |
847 | +# -*- coding: utf-8 -*- |
848 | + |
849 | +from hometab import HomeTab |
850 | +from friendtab import FriendTab |
851 | +from newfriendtab import NewFriendTab |
852 | + |
853 | +from PyQt4.QtGui import QIcon |
854 | +from PyQt4.QtGui import QTabWidget |
855 | +from PyQt4.QtGui import QPixmap |
856 | + |
857 | + |
858 | +class UserTabWidget(QTabWidget): |
859 | + |
860 | + def __init__(self, control, *args): |
861 | + apply(QTabWidget.__init__, (self, ) + args) |
862 | + self._control = control |
863 | + self._control.addUserTabWidget(self) |
864 | + self._addUserTab() |
865 | + self._addFriendTabs() |
866 | + self._addNewFriendTab() |
867 | + |
868 | + def _addUserTab(self): |
869 | + self.addTab(HomeTab(self._control), QIcon(self._control.getGFXPath() + '/home.svg'), u'&Home') |
870 | + |
871 | + def _addFriendTabs(self): |
872 | + order = 0 |
873 | + for friendId in self._control.getStore().getFriends(): |
874 | + (icon, title) = self._getFriendTabInfo(friendId) |
875 | + self.addTab(FriendTab(self._control, friendId), icon, u'%s' % title) |
876 | + self._control.addUserTab((order, friendId)) |
877 | + order+=1 |
878 | + |
879 | + def addFriendTab(self, friendId): |
880 | + pos = self.count()-1 |
881 | + order = pos-1 |
882 | + (icon, title) = self._getFriendTabInfo(friendId) |
883 | + self.insertTab(pos, FriendTab(self._control, friendId), icon, u'%s' % title) |
884 | + self._control.addUserTab((order, friendId)) |
885 | + self.setCurrentIndex(pos) |
886 | + |
887 | + def _getFriendTabInfo(self, uid): |
888 | + email = self._control.getStore().getEmail(uid) |
889 | + |
890 | + if email == None: |
891 | + title = uid[:5] |
892 | + else: |
893 | + title = email.split('@')[0] |
894 | + |
895 | + return (self.getFriendIcon(uid), title) |
896 | + |
897 | + def getFriendIcon(self, uid): |
898 | + mugshot = self._control.getStore().getMugshot(uid) |
899 | + if mugshot: |
900 | + iconData = QPixmap() |
901 | + iconData.loadFromData(mugshot) |
902 | + icon = QIcon(iconData) |
903 | + else: |
904 | + icon = self._loadUnknownMugshot() |
905 | + return icon |
906 | + |
907 | + def _addNewFriendTab(self): |
908 | + self.addTab(NewFriendTab(self._control), u'+') |
909 | + |
910 | + def _loadUnknownMugshot(self): |
911 | + return QIcon(self._control.getGFXPath() + '/mugshot_unknown.svg') |
912 | |
913 | === added file 'src/guicontrol.py' |
914 | --- src/guicontrol.py 1970-01-01 00:00:00 +0000 |
915 | +++ src/guicontrol.py 2009-10-27 21:15:19 +0000 |
916 | @@ -0,0 +1,76 @@ |
917 | +#!/usr/bin/python2.6 |
918 | +# -*- coding: utf-8 -*- |
919 | + |
920 | +from remote import Remote |
921 | +from store import Store |
922 | +from realfs import Realfs |
923 | + |
924 | +import os |
925 | + |
926 | + |
927 | +class GUIControl(object): |
928 | + |
929 | + def __init__(self): |
930 | + self._gfx = '' |
931 | + self._store = Store(Realfs([os.environ['HOME'], '.qfriendslol'])) |
932 | + self._remote = Remote() |
933 | + self._tabW = None |
934 | + self._tabs = [] |
935 | + |
936 | + def setGFXPath(self, path): |
937 | + self._gfx = path |
938 | + |
939 | + def getGFXPath(self): |
940 | + return self._gfx |
941 | + |
942 | + def getRemote(self): |
943 | + return self._remote |
944 | + |
945 | + def getStore(self): |
946 | + return self._store |
947 | + |
948 | + def addUserTabWidget(self, tabW): |
949 | + self._tabW = tabW |
950 | + |
951 | + def addUserTab(self, tuple): |
952 | + self._tabs.append(tuple) |
953 | + |
954 | + def changeEmail(self, email): |
955 | + if not email == self.getStore().getEmail(): |
956 | + self.getStore().putEmail(email) |
957 | + self.getRemote().advertise(email) |
958 | + |
959 | + def changeMugshot(self, mugshot): |
960 | + if not mugshot == self.getStore().getMugshot(): |
961 | + self.getStore().putMugshot(mugshot) |
962 | + self.getRemote().store('mugshot', mugshot) |
963 | + |
964 | + def addUser(self, uid, email = None): |
965 | + self.getStore().addFriend(uid) |
966 | + if email: |
967 | + self.getStore().putEmail(email, uid) |
968 | + self.updateUserData(uid) |
969 | + self._tabW.addFriendTab(uid) |
970 | + |
971 | + def forgetUser(self, uid): |
972 | + self.getStore().removeFriend(uid) |
973 | + index = map(lambda (x,_): x, filter(lambda (_,y): y == uid, |
974 | + self._tabs))[0] |
975 | + self._tabs = filter(lambda (x,_): x < index, self._tabs) + map( |
976 | + lambda (x,y): (x-1,y), filter( |
977 | + lambda (x,_): x > index, self._tabs)) |
978 | + self._tabW.removeTab(index+1) |
979 | + |
980 | + def updateUserData(self, uid): |
981 | + try: |
982 | + rdata = self.getRemote().retrieve('mugshot', uid) |
983 | + except: |
984 | + rdata = None |
985 | + |
986 | + if rdata: |
987 | + self.getStore().putMugshot(rdata, uid) |
988 | + |
989 | + def refreshTab(self, userId): |
990 | + index = map(lambda (x,_): x, filter(lambda (_,y): y == userId, |
991 | + self._tabs))[0]+1 |
992 | + self._tabW.setTabIcon(index, self._tabW.getFriendIcon(userId)) |
993 | |
994 | === added file 'src/qfriendslol.pyw' |
995 | --- src/qfriendslol.pyw 1970-01-01 00:00:00 +0000 |
996 | +++ src/qfriendslol.pyw 2009-10-27 21:15:19 +0000 |
997 | @@ -0,0 +1,31 @@ |
998 | +#!/usr/bin/python2.6 |
999 | +# -*- coding: utf-8 -*- |
1000 | + |
1001 | +from guicontrol import GUIControl |
1002 | +from gui.mainwindow import MainWindow |
1003 | + |
1004 | +import sys |
1005 | +import os.path |
1006 | +from PyQt4.QtGui import QApplication |
1007 | + |
1008 | +def main(): |
1009 | + app = QApplication(sys.argv) |
1010 | + |
1011 | + control = GUIControl() |
1012 | + control.setGFXPath(os.path.dirname(__file__) + '/gfx') |
1013 | + #configTestStore(control.getStore()) |
1014 | + |
1015 | + window = MainWindow(control) |
1016 | + window.show() |
1017 | + |
1018 | + app.exec_() |
1019 | + |
1020 | +def configTestStore(store): |
1021 | + store.putEmail('me@localhost') |
1022 | + store.addFriend('8682065025227700138022978937487170069337') |
1023 | + store.putEmail('frank@gmail.com', '8682065025227700138022978937487170069337') |
1024 | + store.putMugshot(open(os.path.dirname(__file__) + '/../branding/qfriendslol_logo_64x64.png').read(), '8682065025227700138022978937487170069337') |
1025 | + store.addFriend('e4e8743ffd801b2a126de53607c9ccd383fb71b8') |
1026 | + |
1027 | +if __name__ == '__main__': |
1028 | + main() |
1029 | |
1030 | === modified file 'src/remote.py' |
1031 | --- src/remote.py 2009-10-27 14:38:48 +0000 |
1032 | +++ src/remote.py 2009-10-27 21:15:19 +0000 |
1033 | @@ -54,7 +54,7 @@ |
1034 | qfriendslol-1-metsä.jpg → piece1 |
1035 | ''' |
1036 | keyformat = 'qfriendslol-%s-' + filename |
1037 | - block = int(self.get(keyformat % 0, userid)) |
1038 | + block = self.get(keyformat % 0, userid) |
1039 | if block == None: |
1040 | raise Error('Header unavailable') |
1041 | try: |
1042 | @@ -119,24 +119,23 @@ |
1043 | f = open('uppi.jpeg') |
1044 | upattava = f.read() |
1045 | f.close() |
1046 | - r.store('mugshot.jpeg',upattava) |
1047 | + r.store('mugshot',upattava) |
1048 | |
1049 | |
1050 | r.advertise('muumi@golf.uk') |
1051 | users = r.findUser('muumi@golf.uk') |
1052 | user = users[0] |
1053 | print user |
1054 | - (size,time)= r.fileinfo('mugshot.jpeg', user) |
1055 | + (size,time)= r.fileinfo('mugshot', user) |
1056 | |
1057 | from logic import seconds2string |
1058 | print seconds2string(time) |
1059 | print '%sB' % size |
1060 | |
1061 | - r.putfilenames(['mugshot.jpeg']) |
1062 | + r.putfilenames(['mugshot']) |
1063 | |
1064 | - data = r.retrieve('mugshot.jpeg', user) |
1065 | + data = r.retrieve('mugshot', user) |
1066 | |
1067 | - f = open('mugshot.jpeg','w') |
1068 | + f = open('mugshot','w') |
1069 | f.write(data) |
1070 | f.close() |
1071 | - |
1072 | |
1073 | === modified file 'src/store.py' |
1074 | --- src/store.py 2009-10-27 00:55:02 +0000 |
1075 | +++ src/store.py 2009-10-27 21:15:19 +0000 |
1076 | @@ -5,21 +5,21 @@ |
1077 | |
1078 | def __init__(self, fs): |
1079 | self._fs = fs |
1080 | - self._friends = [] |
1081 | + self._updFriends() |
1082 | |
1083 | def putMugshot(self, pic, userid = None): |
1084 | if (userid == None): |
1085 | - self._fs.write(['mugshot.jpeg'], pic) |
1086 | + self._fs.write(['mugshot'], pic) |
1087 | elif self._isValidId(userid) and userid in self.getFriends(): |
1088 | - self._fs.write([self._getFriendFolderName(userid), 'mugshot.jpeg'], pic) |
1089 | + self._fs.write(['friends', self._getFriendFolderName(userid), 'mugshot'], pic) |
1090 | else: |
1091 | raise ValueError |
1092 | |
1093 | def getMugshot(self, userid = None): |
1094 | if (userid == None): |
1095 | - return self._fs.read(['mugshot.jpeg']) |
1096 | + return self._fs.read(['mugshot']) |
1097 | elif self._isValidId(userid) and userid in self.getFriends(): |
1098 | - return self._fs.read([self._getFriendFolderName(userid), 'mugshot.jpeg']) |
1099 | + return self._fs.read(['friends', self._getFriendFolderName(userid), 'mugshot']) |
1100 | else: |
1101 | raise ValueError |
1102 | |
1103 | @@ -27,7 +27,7 @@ |
1104 | if (userid == None): |
1105 | self._fs.write(['email.txt'], email) |
1106 | elif self._isValidId(userid) and userid in self.getFriends(): |
1107 | - self._fs.write([self._getFriendFolderName(userid), 'email.txt'], email) |
1108 | + self._fs.write(['friends', self._getFriendFolderName(userid), 'email.txt'], email) |
1109 | else: |
1110 | raise ValueError |
1111 | |
1112 | @@ -35,7 +35,7 @@ |
1113 | if (userid == None): |
1114 | return self._fs.read(['email.txt']) |
1115 | elif self._isValidId(userid) and userid in self.getFriends(): |
1116 | - return self._fs.read([self._getFriendFolderName(userid), 'email.txt']) |
1117 | + return self._fs.read(['friends', self._getFriendFolderName(userid), 'email.txt']) |
1118 | else: |
1119 | raise ValueError |
1120 | |
1121 | @@ -56,18 +56,19 @@ |
1122 | return map(lambda (_, id): id, self._friends) |
1123 | |
1124 | def _updFriends(self): |
1125 | - self._friends = [] |
1126 | - for item in self._fs.ls(['friends']): |
1127 | - item = item.split('-') |
1128 | - if (len(item) == 2) and (self._isValidId(item[1])): |
1129 | - self._friends.append((item[0], item[1])) |
1130 | + self._friends = filter(lambda (_, uid): self._isValidId(uid), map(lambda folder: tuple(folder.split('-')), self._fs.ls(['friends']))) |
1131 | + |
1132 | |
1133 | def _getFriendFolderName(self, userid): |
1134 | return "%s-%s" % (self._getFriendNum(userid), userid) |
1135 | |
1136 | def _getFriendNum(self, userid): |
1137 | - return map(lambda (order,_): order, filter(lambda (_,id): id == userid, |
1138 | - self._friends))[0] |
1139 | + orders = map(lambda (order,_): order, filter(lambda (_,id): id == userid, |
1140 | + self._friends)) |
1141 | + if orders: |
1142 | + return orders[0] |
1143 | + else: |
1144 | + return -1 |
1145 | |
1146 | def _nextFriendNum(self): |
1147 | max = 0 |
There is working gui, which should be merged in trunk.