示例#1
0
    def OnClose(self, evt):
        # Replace with event handler code
#        print self.Parent
#        print self.Parent.messageFrame[self.friend]
        del self.Parent.messageFrame[self.friend]
        self.Destroy()
        uiDebug("messageUi OnClose()")
示例#2
0
文件: im.py 项目: xiaomdong/xdIm
 def closeEvent(self,evt=None):
     '''关闭事件'''
     uiDebug("parent closeEvent")
     #pylint: disable=E1101 
     reactor.stop()
     self.app.exit()
     uiDebug("parent closeEvent end")
示例#3
0
文件: client.py 项目: xiaomdong/xdIm
    def createMessageFrame(self,QModelIndex):
        '''创建对话窗口'''
        friend= self.userModel.data(QModelIndex)

        if self.userModel.indexFromItem(self.itemFriend) == QModelIndex:
            return
        
        if friend == "":
            return
        
        if friend == "inline":
            return
        
        uiDebug(self.messageFrame)
        if self.messageFrame.has_key(friend):
            self.messageFrame[friend].show()
        else:    
            try:        
                frame = messageWin(self,self.user,friend)
                frame.setWindowTitle(friend)
                self.messageFrame[friend]=frame
                frame.show()
                #pylint: disable=W0702 
            except:
                pass
        
        uiDebug("mainPanelUi createMessageFrame()")
示例#4
0
文件: message.py 项目: xiaomdong/xdIm
 def closeEvent(self,evt):
     '''关闭事件'''
     
     friend=self.windowTitle()
     del self.parent().messageFrame[friend]
     evt.accept()
     uiDebug("messageWin closeEvent")
示例#5
0
 def fileOpen(self, lineEdit, filters):
     openFile = QFileDialog.getOpenFileName(self, "Find Files", QDir.currentPath(), filters="*." + filters)
     uiDebug(openFile)
     if openFile != None :
         lineEdit.setText(openFile[0])
         self.setUserConfig()
         self.showConfig()
示例#6
0
文件: im.py 项目: xiaomdong/xdIm
 def createFriendList(self):
     '''创建主窗口的联系人列表'''
     if self.friends!=None:
         for friend in self.friends:
             uiDebug("* "+friend)    
             if friend!="":
                 self.mainPanel.addLinkMan(friend,"linked")
     uiDebug("createFriendList end")           
示例#7
0
 def readConfig(self, _file):
     '''读取服务器端配置文件'''
     #pylint: disable=W0201
     self.Config = serverConfig(_file)
     self.ControlMedia = self.Config.getControlMedia() 
     self.ControlMediaPath = self.Config.getControlMediaPath()        
     self.language = self.Config.getLanguage()
     self.userConfig()
     uiDebug("readConfig")
示例#8
0
文件: login.py 项目: xiaomdong/xdIm
 def onAccepted(self):
     """确定动作"""
     host = str(self.ui.server_lineEdit.text())
     port = 8002
     user = str(self.ui.user_lineEdit.text())
     password = str(self.ui.password_lineEdit.text())
     uiDebug("host: " + host + ",user: "******",password: "******"loginPanelUi onAccepted()")
示例#9
0
 def OnButton_okButton(self, evt):
     # Replace with event handler code
     host=str(self.serverComboBox.GetValue())
     port=8002
     user=str(self.userComboBox.GetValue())
     password=str(self.passwordTextCtrl.GetLabel())
     password=str(self.passwordTextCtrl.GetValue())
     uiDebug("password:"******"password:"******"loginPanelUi OnButton_okButton()")
示例#10
0
    def addUsers(self, user, instance):
        '''添加一条登陆用户数据'''

        index = self.ui.loginUsers_tableView.selectionModel().currentIndex()
        model = self.ui.loginUsers_tableView.model()
        row = model.rowCount(index.parent())
        model.setItem(row, 0, QStandardItem(user))
        model.setItem(row, 1, QStandardItem(str(instance)))
        
        uiDebug("loginUser")
示例#11
0
 def loadConfig(self):
     '''加载配置文件'''
     configfile = QFileDialog.getOpenFileName(self, "Load Config File", QDir.currentPath(), filter="*.cfg")
     uiDebug(configfile)
     if configfile != None :
         self.readConfig(configfile)
         self.stopServer()
         self.startServer()
         self.showConfig()
     uiDebug("loadConfig") 
示例#12
0
 def handelFailure(self, failure, port):
     uiDebug( "loginPanelUi handelFailure")
     uiDebug(failure.getErrorMessage())
     try:
         message=unicode(failure.getErrorMessage(), self.textencoding)
     except:
         message="Something is Err!"
     dlg = wx.MessageDialog(None, message,
                            "A Message Box",
                            wx.YES_NO )
     dlg.ShowModal()
示例#13
0
    def killUser(self):
        '''踢出一个用户'''
        try:
            index = self.ui.loginUsers_tableView.selectionModel().currentIndex()
            model = self.ui.loginUsers_tableView.model()
            user = model.item(index.row(), 0).index().data()
            self.connect.killUser(user)
            #pylint: disable=W0702
        except:
            pass    
#        model.removeRow(index.row(), index.parent())
        uiDebug("killUser")
示例#14
0
 def about(self):
     '''about'''
     aboutInfo = '''<HTML>
      <p>xdIm ver 0.2.0</p>
      <p>xdIm program is a software program by xd.</p>
      <p>Copy Right : "(C) 2008-2010 Programmers and Coders Everywhere"</p>
      <p><a href="http://www.xdIm.org/">http://www.xdIm.org</a></p>
      </HTML>"'''
      
     tranAboutInfo = QApplication.translate("MainWindow", aboutInfo, None, QApplication.UnicodeUTF8)
     QMessageBox.information(self, "xdIm information", tranAboutInfo)
     uiDebug("about") 
示例#15
0
 def choiceSql(self):
     uiDebug("choiceMysql")
     self.ui.text_groupBox.setChecked(False)
     self.ui.xml_groupBox.setChecked(False)
     if  self.ui.sqlTypeComboBox.currentText() == mysql:
         self.ui.openSqlpushButton.setDisabled(True)
         self.ui.userLineEdit.setEnabled(True)
         self.ui.passwordlineEdit.setEnabled(True)   
         
     if  self.ui.sqlTypeComboBox.currentText() == sqlite:
         self.ui.openSqlpushButton.setEnabled(True)
         self.ui.userLineEdit.setDisabled(True)
         self.ui.passwordlineEdit.setDisabled(True)
示例#16
0
文件: im.py 项目: xiaomdong/xdIm
 def refreshReceMessage(self,src,dst,message):
     '''收到服务器的消息时,更新消息接收文本框'''
     if self.mainPanel.messageFrame.has_key(src):
         pass
     else:
         #如果没有窗口,重新创建窗口
         self.mainPanel.createTempMessageFrame(self.user,src)
         
     try: 
         self.mainPanel.messageFrame[src].receMessage(message)
         #pylint: disable=W0702                 
     except:
         uiDebug("im refreshReceMessage error " + src +" " +dst)
示例#17
0
    def stopServer(self):
        ''' #停止服务'''
        if self.connect != None:
            self.ui.startServer_pushButton.setEnabled(True)
            self.ui.stopServer_pushButton.setEnabled(False)
            self.ui.mysql_groupBox.setDisabled(False)
            self.ui.text_groupBox.setDisabled(False)
            self.ui.xml_groupBox.setDisabled(False)  
            #pylint: disable=E1101          
            reactor.disconnectAll()
#            self.clearUserInfo()
            self.statusBar().showMessage("server is stopped!")
        uiDebug("stopServer")
示例#18
0
    def userInfoAddRow(self):
        '''添加一条用户数据'''
#        self.userModel.appendRow(QStandardItem(""))
        index = self.ui.userInfo_tableView.selectionModel().currentIndex()
        model = self.ui.userInfo_tableView.model()

        if not model.insertRow(index.row() + 1, index.parent()):
            return

        for column in range(model.columnCount(index.parent())):
            child = model.index(index.row() + 1, column, index.parent())
            model.setData(child, "[No data]", Qt.EditRole)
            
        uiDebug("userInfoAddRow")
示例#19
0
    def setUserConfig(self):
        '''保留用户配置'''
        if self.ui.xml_groupBox.isChecked() == True:
            if self.ui.xml_lineEdit.text() != "":
                self.ControlMedia = xml
                self.ControlMediaPath = self.ui.xml_lineEdit.text()
                uiDebug("setUserConfig xml: " + xml)
         
        if self.ui.text_groupBox.isChecked() == True:
            if self.ui.text_lineEdit.text() != "":
                self.ControlMedia = txt
                self.ControlMediaPath = self.ui.text_lineEdit.text()
                uiDebug("setUserConfig txt: " + txt)
         
        if self.ui.mysql_groupBox.isChecked() == True:
            if self.ui.sqlTypeComboBox.currentText() == mysql:
                self.ControlMedia = mysql
                uiDebug("setUserConfig mysql: " + mysql)
            if self.ui.sqlTypeComboBox.currentText() == sqlite:
                self.ControlMedia = sqlite
                uiDebug("setUserConfig sqlite: " + sqlite)
            self.ControlMediaPath = self.ui.ServerLineEdit.text()

        self.Config.setContrlMedia(self.ControlMedia)
        self.Config.setControlMediaPath(self.ControlMediaPath)
        self.userConfig()    
示例#20
0
    def removeUser(self, user):
        '''删除一条登陆用户数据'''
        index = self.ui.loginUsers_tableView.selectionModel().currentIndex()
        model = self.ui.loginUsers_tableView.model()
        maxRow = model.rowCount(index.parent())
#        print user
        for row in range(maxRow):
#            print row
#            print model.item(row, 0).index().data()
#            print type(model.item(row, 0).index().data())
            if user == model.item(row, 0).index().data():
                model.removeRow(row, index.parent())                             
                
        uiDebug("logoutUser")
示例#21
0
文件: client.py 项目: xiaomdong/xdIm
 def createTempMessageFrame(self,user,friend):
     uiDebug(self.messageFrame)
     if self.messageFrame.has_key(friend):
         self.messageFrame[friend].show()
     else:    
         try:        
             frame = messageWin(self,user,friend)
             frame.setWindowTitle(friend)
             self.messageFrame[friend]=frame
             frame.show()
             #pylint: disable=W0702 
         except:
             pass
     
     uiDebug("mainPanelUi createMessageFrame()")
示例#22
0
    def userInfoDelRow(self):
        '''删除数据,且保留此次删除的数据'''
        model = self.ui.userInfo_tableView.model()
        index = self.ui.userInfo_tableView.selectionModel().currentIndex()
        user = model.item(index.row(), 0).index().data()
        friendlist = model.item(index.row(), 1).index().data()
        self.delUsrInfo = [index.row(), user, friendlist]
#        print self.delUsrInfo
        try:
            model.removeRow(index.row(), index.parent())
            self.users.deleteUser(user)
            self.users.userDataSave()
            #pylint: disable=W0702 
        except:    
            pass        
        uiDebug("userInfoDelRow")        
示例#23
0
    def OnTool_sendTool(self, evt):
        # Replace with event handler code
        msg=self.sendMessageText.GetValue()
        if msg=="":
            return
        if self.friend != self.user :
#            data=u"mesS desS %s desE souS %s souE conS %s conE mesE\r\n"%(self.friend,self.user,msg)
#            self.Parent.Parent.connecting.protocolInstance.dataSend(data)
#            data=u"mesS desS %s desE souS %s souE conS %s conE mesE\r\n"%(self.friend,self.user,msg)
            self.Parent.Parent.connecting.protocolInstance.messageSend(self.friend,self.user,msg)
            self.sendMessageText.Clear()
            self.receMessageText.AppendText("\n"+"you said: "+msg)
        else:
            self.receMessageText.AppendText("\n"+"you said: "+msg)
            self.sendMessageText.Clear()
            pass    
        uiDebug("messageUi OnTool_sendTool()")
示例#24
0
    def startServer(self):
        '''#启动服务'''
        self.ui.startServer_pushButton.setEnabled(False)
        self.ui.stopServer_pushButton.setEnabled(True)
        self.connect = server_twisted.serverMain(8002, self.users)
        self.saveConfig()
#        self.readConfig(configFile)
        self.userConfig()
        self.ui.mysql_groupBox.setDisabled(True)
        self.ui.text_groupBox.setDisabled(True)
        self.ui.xml_groupBox.setDisabled(True)
        self.statusBar().showMessage("server is starting!")
        
        if self.users != None:
            self.clearUserInfo()
            self.showUserinfo()
        uiDebug("startServer")
示例#25
0
 def userInfoUndoDelRow(self):
     '''恢复前次删除的数据'''
     if self.delUsrInfo != None:
         model = self.ui.userInfo_tableView.model()
         if not model.insertRow(self.delUsrInfo[0]):
             return
         user = self.delUsrInfo[1]
         friendlist = self.delUsrInfo[2]      
         self.userModel.setItem(self.delUsrInfo[0], 0, QStandardItem(user))
         self.userModel.setItem(self.delUsrInfo[0], 1, QStandardItem(friendlist))
         if user != "[No data]":
             self.users.addUser(user, "admin")
         if friendlist != "[No data]":    
             for friend in friendlist.split(","):            
                 self.users.addUserFriend(user, friend)
         self.users.userDataSave()    
     self.delUsrInfo = None        
     uiDebug("userInfoUndoDelRow")
示例#26
0
 def userInfoSaveData(self):
     '''保留用户数据'''
     if self.users:
         model = self.ui.userInfo_tableView.model()
         index = self.ui.userInfo_tableView.selectionModel().currentIndex()
         for row in range(model.rowCount(index.parent())):
             user = model.item(row, 0).index().data()
             friendlist = model.item(row, 1).index().data()
             if user != "[No data]":
                 self.users.addUser(user, "admin")
             if friendlist != "[No data]":
                 for friend in friendlist.split(","):
                     if friend != '':
                         self.users.addUserFriend(user, friend)   
     
         self.users.userDataSave()
         self.clearUserInfo()    
         self.showUserinfo()
     uiDebug("userInfoSaveData")        
示例#27
0
文件: im.py 项目: xiaomdong/xdIm
 def updatePanel(self):
     '''登录服务器成功后,更新用户界面,由客户端协议调用'''
     uiDebug("updatePanel start")
     uiDebug(self.friends)
     self.login.hide()
     self.show()
     self.login.destroy()
     del self.login
     self.createFriendList()
         
     uiDebug("updatePanel end")
示例#28
0
文件: im.py 项目: xiaomdong/xdIm
 def connectServer(self,host,port,user,password):
     '''连接服务器,由login界面登录时调用'''
     self.user=user
     client_twisted.frame = self
     self.connecting=client_twisted.clientMain(host,port,user,password)
     uiDebug( "connectServer")
示例#29
0
文件: im.py 项目: xiaomdong/xdIm
 def setUserFriends(self,friends):
     '''设置用户Friends 由客户端协议调用'''
     uiDebug("im setUserFriends start")
     self.friends=friends    
     uiDebug("im setUserFriends end")
示例#30
0
 def saveConfig(self):
     '''保留配置文件'''
     self.setUserConfig()
     self.Config.saveServerConfig()
     uiDebug("saveConfig")