def on_sms_button_clicked(self, button): self._logger.debug("entered on_sms_button_clicked") contact_point = self._contact.contact_points[ self._active_contact_point_index] self._logger.debug("contact is %s, contact_point is %s", self._contact, contact_point) window_manager = gtkapplication.ui.gtk.window_manager.WindowManager() window_manager.get_sms_window(self._contact, self._active_contact_point_index, True)
def process_sip_text_message(self, prm): self._logger.debug("Entered process_sip_text_message") self._logger.debug("prm.fromUri = %s", prm.fromUri) self._logger.debug("prm.toUri = %s", prm.toUri) self._logger.debug("prm.msgBody = %s", prm.msgBody) contact_manager = gtkapplication.api.contacts.contact_manager.ContactManager( ) (contact, active_contact_point_index) = contact_manager.find_contact_by_sip_uri( prm.fromUri, True) self._logger.debug("after find_contact_by_sip_uri") db_access = gtkapplication.api.sip.business_layer.BusinessLayer() db_access.insert_sms_message(prm.fromUri, prm.msgBody, SmsDirection.RECEIVED) self._logger.debug("after db.insert_sms_message") window_manager = gtkapplication.ui.gtk.window_manager.WindowManager() if len(gtkapplication.api.sip.sip_call_state.sip_calls) == 0: self._logger.debug("no current call, making sms window present") sms_window = window_manager.get_sms_window( contact, active_contact_point_index, True) dashboard_ui = window_manager.get_dashboard_window(True) sms_window.display_sms(prm.msgBody, SmsDirection.RECEIVED, datetime.datetime.now()) self._logger.debug("after sms_window.display_sms") sms_dto = gtkapplication.ui.sms.SmsDto(datetime.datetime.now(), contact, prm.msgBody, [], active_contact_point_index) dashboard_ui.add_new_free_buddy_text_notification(sms_dto) gtkapplication.api.audio.ringer.start_ringer() self._logger.debug( "after gtkapplication.api.audio.ringer.start_ringer()") else: self._logger.debug("current sip call, NOT making windows present") sms_window = window_manager.get_sms_window( contact, active_contact_point_index, False) dashboard_ui = window_manager.get_dashboard_window(False) sms_window.display_sms(prm.msgBody, SmsDirection.RECEIVED, datetime.datetime.now()) self._logger.debug("after sms_window.display_sms") sms_dto = gtkapplication.ui.sms.SmsDto(datetime.datetime.now(), contact, prm.msgBody, [], active_contact_point_index) dashboard_ui.add_new_free_buddy_text_notification(sms_dto) self._logger.debug( "after dashboard_ui.add_new_free_buddy_text_notification") window_manager = gtkapplication.ui.gtk.window_manager.WindowManager( ) window_manager.get_contacts_window()
def process_sms_message(self, message_body): self._logger.debug("entered process_sms_message") message_lines = message_body.split('\n') message_first_line = message_lines[0] message_body = '\n'.join(message_lines[1:]) from_phone_number = message_first_line.split('=')[1] self._logger.debug('from_phone_number = %s', from_phone_number) (message_stripped_of_links, links) = self._extract_links(message_body) message_body = message_stripped_of_links.strip() self._logger.debug("message_body after strip() = '%s'", message_body) db = gtkapplication.api.sip.business_layer.BusinessLayer() sms_message_row_id = db.insert_sms_message(from_phone_number, message_body, SmsDirection.RECEIVED) contact_manager = gtkapplication.api.contacts.contact_manager.ContactManager( ) (contact, active_contact_point_index ) = contact_manager.find_contact_by_phone_number( from_phone_number, True) window_manager = gtkapplication.ui.gtk.window_manager.WindowManager() sms_window = window_manager.get_sms_window(contact, active_contact_point_index, True) dashboard_ui = window_manager.get_dashboard_window(True) if message_body != "": self._logger.debug("display_sms with message body %s", message_body) sms_window.display_sms(message_body, SmsDirection.RECEIVED, datetime.datetime.now()) if len(links) > 0: for link in links: self._logger.debug("processing link %s", link) content_type = self._get_content_type(link) file_extension = mimetypes.guess_extension(content_type) self._logger.debug("link has content_type %s", content_type) self._logger.debug("link has extension %s", file_extension) db.insert_mms_link(sms_message_row_id, link, content_type) if content_type in ['image/jpeg', 'image/gif', 'image/png']: self._logger.debug("auto displaying picture") sms_window.display_mms(link, SmsDirection.RECEIVED, datetime.datetime.now(), content_type, file_extension) else: self._logger.debug( "not a supported picture, not auto displaying link. Content type: '%s', link: '%s'", content_type, link) sms_window.display_sms( "Content Type : " + content_type + "\n" + link, SmsDirection.RECEIVED, datetime.datetime.now()) sms_dto = gtkapplication.ui.sms.SmsDto(datetime.datetime.now(), contact, message_body, links, active_contact_point_index) dashboard_ui.add_new_sms_notification(sms_dto) gtkapplication.api.audio.ringer.start_ringer()
def on_retry_button_clicked(self, button): self._logger.debug('entered on_retry_button_click') window_manager = gtkapplication.ui.gtk.window_manager.WindowManager() contact = self._sms_delivery_failure_dto.contact self._logger.debug('contact = %s', contact) active_contact_point_index = self._sms_delivery_failure_dto.active_contact_point_index self._logger.debug('active_contact_point_index = %s', active_contact_point_index) message = self._sms_delivery_failure_dto.on_instant_message_status_param.msgBody self._logger.debug('message = %s', message) sms_window = window_manager.get_sms_window(contact, active_contact_point_index, message) self._logger.debug("after get_sms_window()") sms_window.send_sms(contact, active_contact_point_index, message) self._logger.debug("after sms_window.send_sms()")
def onSignalMessageReceived(timestamp,source,groupID,message,attachments): _logger.debug("entered onSignalMessageReceived") _logger.debug("Message '%s' received in group '%s'",message,gtkapplication.api.signal.signal_state.signal.getGroupName(groupID)) _logger.debug("source = '%s', attachments = '%s', timestamp='%s'",source,attachments,timestamp) contact_manager=gtkapplication.api.contacts.contact_manager.ContactManager() (from_contact,active_contact_point_index)=contact_manager.find_contact_by_phone_number(source) if from_contact is None: from_contact=gtkapplication.api.contacts.contact.Contact("Unknown") contact_point=gtkapplication.api.contacts.contact_point.ContactPoint("x-signal","Signal",source) from_contact.selected_contact_point=contact_point active_contact_point_index=0 to_contact="me ({0})".format(gtkapplication.data.config_data.PROFILE_DATA['my_phone_number']) window_manager=gtkapplication.ui.gtk.window_manager.WindowManager() sms_window=window_manager.get_sms_window(from_contact,active_contact_point_index,False) formatted_message="Date/Time: {0}\nFrom: {1}.\nTo: {2}\nBody:{3}\n\n".format(datetime.datetime.now(),from_contact,to_contact,message) _logger.debug("formatted_message = %s",formatted_message) sms_window.append_message_to_conversation(formatted_message) links=[] for attachment in attachments: link="file:///"+attachment _logger.debug("created link %s",link) links.append(link) sms_window.add_link_buttons_to_ui(links) _logger.debug("added %d links to window",len(links))
def on_sms_button_clicked(self, button): self._logger.debug("entered on_sms_button_clicked") window_manager = gtkapplication.ui.gtk.window_manager.WindowManager() window_manager.get_sms_window(self._sms_dto.contact, self._sms_dto.active_contact_point_index, True)