| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | import gtkgui_helpers |
|---|
| 15 | |
|---|
| 16 | from common import gajim |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | TYPE_CHAT = 'chat' |
|---|
| 20 | TYPE_GC = 'gc' |
|---|
| 21 | TYPE_PM = 'pm' |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | class MessageControl: |
|---|
| 26 | '''An abstract base widget that can embed in the gtk.Notebook of a MessageWindow''' |
|---|
| 27 | |
|---|
| 28 | def __init__(self, type_id, parent_win, widget_name, contact, account, resource = None): |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | self.handlers = {} |
|---|
| 32 | self.type_id = type_id |
|---|
| 33 | self.parent_win = parent_win |
|---|
| 34 | self.widget_name = widget_name |
|---|
| 35 | self.contact = contact |
|---|
| 36 | self.account = account |
|---|
| 37 | self.hide_chat_buttons_current = False |
|---|
| 38 | self.resource = resource |
|---|
| 39 | |
|---|
| 40 | gajim.last_message_time[self.account][self.get_full_jid()] = 0 |
|---|
| 41 | |
|---|
| 42 | self.xml = gtkgui_helpers.get_glade('message_window.glade', widget_name) |
|---|
| 43 | self.widget = self.xml.get_widget(widget_name) |
|---|
| 44 | |
|---|
| 45 | def get_full_jid(self): |
|---|
| 46 | fjid = self.contact.jid |
|---|
| 47 | if self.resource: |
|---|
| 48 | fjid += '/' + self.resource |
|---|
| 49 | return fjid |
|---|
| 50 | |
|---|
| 51 | def set_control_active(self, state): |
|---|
| 52 | '''Called when the control becomes active (state is True) |
|---|
| 53 | or inactive (state is False)''' |
|---|
| 54 | pass |
|---|
| 55 | |
|---|
| 56 | def allow_shutdown(self, method): |
|---|
| 57 | '''Called to check is a control is allowed to shutdown. |
|---|
| 58 | If a control is not in a suitable shutdown state this method |
|---|
| 59 | should return False''' |
|---|
| 60 | |
|---|
| 61 | return True |
|---|
| 62 | |
|---|
| 63 | def shutdown(self): |
|---|
| 64 | |
|---|
| 65 | pass |
|---|
| 66 | |
|---|
| 67 | def repaint_themed_widgets(self): |
|---|
| 68 | pass |
|---|
| 69 | |
|---|
| 70 | def update_ui(self): |
|---|
| 71 | pass |
|---|
| 72 | |
|---|
| 73 | def toggle_emoticons(self): |
|---|
| 74 | pass |
|---|
| 75 | |
|---|
| 76 | def update_font(self): |
|---|
| 77 | pass |
|---|
| 78 | |
|---|
| 79 | def update_tags(self): |
|---|
| 80 | pass |
|---|
| 81 | |
|---|
| 82 | def get_tab_label(self, chatstate): |
|---|
| 83 | '''Return a suitable the tab label string. Returns a tuple such as: |
|---|
| 84 | (label_str, color) either of which can be None |
|---|
| 85 | if chatstate is given that means we have HE SENT US a chatstate and |
|---|
| 86 | we want it displayed''' |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | pass |
|---|
| 91 | |
|---|
| 92 | def get_tab_image(self): |
|---|
| 93 | '''Return a suitable tab image for display. None clears any current label.''' |
|---|
| 94 | return None |
|---|
| 95 | |
|---|
| 96 | def prepare_context_menu(self): |
|---|
| 97 | |
|---|
| 98 | return None |
|---|
| 99 | |
|---|
| 100 | def chat_buttons_set_visible(self, state): |
|---|
| 101 | |
|---|
| 102 | self.hide_chat_buttons_current = state |
|---|
| 103 | |
|---|
| 104 | def got_connected(self): |
|---|
| 105 | pass |
|---|
| 106 | |
|---|
| 107 | def got_disconnected(self): |
|---|
| 108 | pass |
|---|
| 109 | |
|---|
| 110 | def get_specific_unread(self): |
|---|
| 111 | return len(gajim.events.get_events(self.account, self.contact.jid)) |
|---|
| 112 | |
|---|
| 113 | def send_message(self, message, keyID = '', type = 'chat', |
|---|
| 114 | chatstate = None, msg_id = None, composing_xep = None, resource = None, |
|---|
| 115 | user_nick = None): |
|---|
| 116 | '''Send the given message to the active tab. Doesn't return None if error |
|---|
| 117 | ''' |
|---|
| 118 | jid = self.contact.jid |
|---|
| 119 | |
|---|
| 120 | return gajim.connections[self.account].send_message(jid, message, keyID, |
|---|
| 121 | type = type, chatstate = chatstate, msg_id = msg_id, |
|---|
| 122 | composing_xep = composing_xep, resource = self.resource, |
|---|
| 123 | user_nick = user_nick) |
|---|