Mercurial > libervia-web
comparison libervia.py @ 282:ae3ec654836d
browser_side: added blog item modification/deletion
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 10 Dec 2013 09:07:03 +0100 |
parents | 1ccdc34cfb60 |
children | 4f0c2fea358a |
comparison
equal
deleted
inserted
replaced
281:36ce989c73a5 | 282:ae3ec654836d |
---|---|
117 "getHistory", "getPresenceStatus", "joinMUC", "mucLeave", "getRoomsJoined", | 117 "getHistory", "getPresenceStatus", "joinMUC", "mucLeave", "getRoomsJoined", |
118 "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", | 118 "inviteMUC", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", |
119 "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective", | 119 "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective", |
120 "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", | 120 "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", |
121 "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction", | 121 "getEntityData", "getParamsUI", "asyncGetParamA", "setParam", "launchAction", |
122 "disconnect", "chatStateComposing", "getNewAccountDomain", "confirmationAnswer" | 122 "disconnect", "chatStateComposing", "getNewAccountDomain", "confirmationAnswer", |
123 "syntaxConvert" | |
123 ]) | 124 ]) |
124 | 125 |
125 | 126 |
126 class BridgeSignals(LiberviaJsonProxy): | 127 class BridgeSignals(LiberviaJsonProxy): |
127 RETRY_BASE_DELAY = 1000 | 128 RETRY_BASE_DELAY = 1000 |
456 | 457 |
457 def _personalEventCb(self, sender, event_type, data): | 458 def _personalEventCb(self, sender, event_type, data): |
458 if not self.initialised: | 459 if not self.initialised: |
459 self.init_cache.append((sender, event_type, data)) | 460 self.init_cache.append((sender, event_type, data)) |
460 return | 461 return |
462 sender = JID(sender).bare | |
461 if event_type == "MICROBLOG": | 463 if event_type == "MICROBLOG": |
462 if not 'content' in data: | 464 if not 'content' in data: |
463 print ("WARNING: No content found in microblog data") | 465 print ("WARNING: No content found in microblog data") |
464 return | 466 return |
465 if 'groups' in data: | 467 if 'groups' in data: |
471 for lib_wid in self.libervia_widgets: | 473 for lib_wid in self.libervia_widgets: |
472 if isinstance(lib_wid, panels.MicroblogPanel): | 474 if isinstance(lib_wid, panels.MicroblogPanel): |
473 self.addBlogEntry(lib_wid, sender, _groups, mblog_entry) | 475 self.addBlogEntry(lib_wid, sender, _groups, mblog_entry) |
474 | 476 |
475 if sender == self.whoami.bare: | 477 if sender == self.whoami.bare: |
476 self.mblog_cache.append((_groups, mblog_entry)) | 478 found = False |
477 if len(self.mblog_cache) > MAX_MBLOG_CACHE: | 479 for index in xrange(0, len(self.mblog_cache)): |
478 del self.mblog_cache[0:len(self.mblog_cache - MAX_MBLOG_CACHE)] | 480 entry = self.mblog_cache[index] |
481 if entry[1].id == mblog_entry.id: | |
482 # replace existing entry | |
483 self.mblog_cache.remove(entry) | |
484 self.mblog_cache.insert(index, (_groups, mblog_entry)) | |
485 found = True | |
486 break | |
487 if not found: | |
488 self.mblog_cache.append((_groups, mblog_entry)) | |
489 if len(self.mblog_cache) > MAX_MBLOG_CACHE: | |
490 del self.mblog_cache[0:len(self.mblog_cache - MAX_MBLOG_CACHE)] | |
491 elif event_type == 'MICROBLOG_DELETE': | |
492 for lib_wid in self.libervia_widgets: | |
493 if isinstance(lib_wid, panels.MicroblogPanel): | |
494 lib_wid.removeEntry(data['type'], data['id']) | |
495 print self.whoami.bare, sender, data['type'] | |
496 if sender == self.whoami.bare and data['type'] == 'main_item': | |
497 for index in xrange(0, len(self.mblog_cache)): | |
498 entry = self.mblog_cache[index] | |
499 if entry[1].id == data['id']: | |
500 self.mblog_cache.remove(entry) | |
501 break | |
479 | 502 |
480 def addBlogEntry(self, mblog_panel, sender, _groups, mblog_entry): | 503 def addBlogEntry(self, mblog_panel, sender, _groups, mblog_entry): |
481 """Check if an entry can go in MicroblogPanel and add to it | 504 """Check if an entry can go in MicroblogPanel and add to it |
482 @param mblog_panel: MicroblogPanel instance | 505 @param mblog_panel: MicroblogPanel instance |
483 @param sender: jid of the entry sender | 506 @param sender: jid of the entry sender |