def send_text(self,buddy,text_data):
		self._logger.debug('entered send_text')
		send_im_param=pj.SendInstantMessageParam()
		send_im_param.content=text_data
		send_im_param.userData=None
		buddy.sendInstantMessage(send_im_param)
		self._logger.debug("sent instant msg %s to %s",text_data,str(buddy))
Exemplo n.º 2
0
    def updateCallState(self, thecall, info=None):
        # info is optional here, just to avoid calling getInfo() twice (in the caller and here)
        if not info: info = thecall.getInfo()

        if info.state < pj.PJSIP_INV_STATE_CONFIRMED:
            self._gui.audioUpdateState(thecall.peerUri,
                                       gui.AudioState.INITIALIZING)
        elif info.state == pj.PJSIP_INV_STATE_CONFIRMED:
            self._gui.audioUpdateState(thecall.peerUri,
                                       gui.AudioState.CONNECTED)
            if not self.isPrivate():
                # inform peer about conference participants
                conf_welcome_str = '\n---\n'
                conf_welcome_str += 'Welcome to the conference, participants:\n'
                conf_welcome_str += '%s (host)\n' % (self._acc.cfg.idUri)
                for p in self._participantList:
                    conf_welcome_str += '%s\n' % (str(p))
                conf_welcome_str += '---\n'
                send_im_param = pj.SendInstantMessageParam()
                send_im_param.content = conf_welcome_str
                try:
                    thecall.sendInstantMessage(send_im_param)
                except:
                    pass

                # inform others, including self
                msg = "[Conf manager] %s has joined" % (thecall.peerUri)
                self.addMessage(None, msg)
                self._sendInstantMessage(msg, thecall.peerUri)

        elif info.state == pj.PJSIP_INV_STATE_DISCONNECTED:
            if info.lastStatusCode / 100 != 2:
                self._gui.audioUpdateState(thecall.peerUri,
                                           gui.AudioState.FAILED)
            else:
                self._gui.audioUpdateState(thecall.peerUri,
                                           gui.AudioState.DISCONNECTED)

            # reset entry in the callList
            try:
                idx = self._callList.index(thecall)
                if idx >= 0: self._callList[idx] = None
            except:
                pass

            self.addMessage(
                None, "Call to '%s' disconnected: %s" %
                (thecall.peerUri, info.lastReason))

            # kick the disconnected participant, but the last (avoid zombie chat)
            if not self.isPrivate():
                self.kickParticipant(ParseSipUri(thecall.peerUri))

                # inform others, including self
                msg = "[Conf manager] %s has left" % (thecall.peerUri)
                self.addMessage(None, msg)
                self._sendInstantMessage(msg, thecall.peerUri)
Exemplo n.º 3
0
    def _send_message(self, event):
        msg = self.message.get()
        if msg != '':
            msg_prm = pj.SendInstantMessageParam()
            msg_prm.content = msg
            self.bud.sendInstantMessage(msg_prm)

            self.add_message(msg, MessageState.SEND)
            self.message.delete(0, 'end')
	def send_file(self,buddy,file_path):
		(mime_type,mime_encoding)=mimetypes.guess_type(file_path)
		self._logger.debug('mime_type = %s',mime_type)
		self._logger.debug('mime_encoding = %s',mime_encoding)
		if mime_type is None:
			self._logger.debug('could not determine mime type for file %s',file_path)
		else:
			with open(file_path,'rb')as file_reader:
				file_contents_bytes=file_reader.read()
				file_reader.close()
			self._logger.debug('len(file_contents_bytes) = %s',file_contents_bytes)
			base64_data=codecs.encode(file_contents_bytes,'base64')
			string_data=base64_data.decode('utf-8')
			send_im_param=pj.SendInstantMessageParam()
			send_im_param.content=string_data
			send_im_param.contentType=mime_type
			buddy.sendInstantMessage(send_im_param)
			self._logger.debug("sent binary instant msg with length %d to %s",len(file_contents_bytes),str(buddy))
			buddy=None
			self._logger.debug('buddy set to None')
Exemplo n.º 5
0
	def _sendInstantMessage(self, msg, sender_uri_str=''):
		sender_uri = ParseSipUri(sender_uri_str) if sender_uri_str else None
		send_im_param = pj.SendInstantMessageParam()
		send_im_param.content = str(msg)
		for idx, p in enumerate(self._participantList):
			# don't echo back to the original sender
			if sender_uri and p == sender_uri:
				continue
				
			# send via call, if any, or buddy
			target = None
			if self._callList[idx] and self._callList[idx].connected:
				target = self._callList[idx]
			else:
				target = self._buddyList[idx]
			assert(target)
			
			try:
				target.sendInstantMessage(send_im_param)
			except:
				# error will be handled via Account::onInstantMessageStatus()
				pass