Esempio n. 1
0
    def __init__(self):
        self.qt_app = QtWidgets.QApplication(sys.argv)
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # list1 =[]
        self.ui.pushButton.pressed.connect(self.connect)
        self.ui.pushButton.pressed.connect(self.get_host_with_port)
        self.ui.pushButton.pressed.connect(self.change_profile_name)
        self.ui.pushButton.pressed.connect(self.disable_button)
        self.ui.pushButton_2.pressed.connect(self.logout_button)
        self.ui.pushButton_7.pressed.connect(self.subscribe_button)
        self.ui.pushButton_3.pressed.connect(self.unsubscribe_button)
        self.ui.pushButton_4.pressed.connect(self.unblock_button)
        self.ui.pushButton_6.pressed.connect(self.block_button)
        self.ui.pushButton_9.pressed.connect(self.send_message_button)
        self.ui.pushButton_5.pressed.connect(self.share_twit_button)
Esempio n. 2
0
    def __init__(self, logQueue):
        self.logQueue = logQueue

        self.qt_app = QtWidgets.QApplication(sys.argv)
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # list1 =[]
        self.ui.connect_button.pressed.connect(self.connect)
        # self.ui.connect_button.pressed.connect(self.get_host_with_port)
        self.ui.connect_button.pressed.connect(self.change_profile_name)
        # self.ui.connect_button.pressed.connect(self.disable_button)
        self.ui.LogOut_button.pressed.connect(self.logout_button)
        self.ui.Subscribe_button.pressed.connect(self.subscribe_button)
        self.ui.UnSubscribe_button.pressed.connect(self.unsubscribe_button)
        self.ui.UnBlock_button.pressed.connect(self.unblock_button)
        self.ui.Block_button.pressed.connect(self.block_button)
        self.ui.SendMessage_button.pressed.connect(self.send_message_button)
        self.ui.Share_button.pressed.connect(self.share_twit_button)
        self.initializeIpPort()
Esempio n. 3
0
class ProjectUi(QtWidgets.QMainWindow):
    def __init__(self, logQueue):
        self.logQueue = logQueue

        self.qt_app = QtWidgets.QApplication(sys.argv)
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # list1 =[]
        self.ui.connect_button.pressed.connect(self.connect)
        # self.ui.connect_button.pressed.connect(self.get_host_with_port)
        self.ui.connect_button.pressed.connect(self.change_profile_name)
        # self.ui.connect_button.pressed.connect(self.disable_button)
        self.ui.LogOut_button.pressed.connect(self.logout_button)
        self.ui.Subscribe_button.pressed.connect(self.subscribe_button)
        self.ui.UnSubscribe_button.pressed.connect(self.unsubscribe_button)
        self.ui.UnBlock_button.pressed.connect(self.unblock_button)
        self.ui.Block_button.pressed.connect(self.block_button)
        self.ui.SendMessage_button.pressed.connect(self.send_message_button)
        self.ui.Share_button.pressed.connect(self.share_twit_button)
        self.ui.Pubkey_button.pressed.connect(self.pubkey_button)
        self.initializeIpPort()

        #self.list =QtWidgets.QListWidget(self)

    def initializeIpPort(self):
        self.ui.ip_field.setText("127.0.0.1")
        self.ui.port_field.setText("12346")
        self.ui.username_field.setText("Mustafa")
        self.UUIDtoConnect = uuid.uuid4()

    def connect(self):
        self.get_host_with_port()
        pass

    def pubkey_button(self):
        # pubkey buttonuna basıldığında gerçekleştirilecek eylem
        request = "PBKEY:" + "BUNUIMZALA"
        # myClient = yay.ClientThread("Client Thread", self.UUIDtoConnect ,self.ip, self.port, request, self.logQueue)
        myClient = yay.ClientThread("Client Thread", self.ip, self.port,
                                    request, self.logQueue)
        response = myClient.control()
        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")
        pass

    def refresh_feed_button(self):
        # takip edilen kişilerin serverlarına istek atarak twitleri yeniler
        pass

    def send_message_button(self):
        # Send message to followed içine yazılan text yalnızca
        # followers içinde check edilen kişilere gönderilecektir
        pass

    def block_button(self):
        # Followers içindeki kullanıcılardan check edilenleri engelleyecektir.
        pass

    def unblock_button(self):
        # Blocked içindeki kullanıcılardan check edilenlerin engellerini kaldıracaktır.
        pass

    def unsubscribe_button(self):
        # Followed içindeki kullanıcılardan check edilenleri takipten çıkacaktır.
        pass

    def subscribe_button(self):
        # Suggested users içindeki kullanıcılardan check edilenleri takip edecektir.
        pass

    def logout_button(self):
        # logout ui kapatma olarak tasarlanmıştır. ileride connection close olarak değiştirilebilir
        self.close()

    def disable_button(self):
        self.ui.connect_button.setDisabled(True)

    def get_host_with_port(self):
        # ip ve port alma işlemi
        self.ip = self.ui.ip_field.text()
        self.port = self.ui.port_field.text()
        self.UUID = "AraciUUID"
        yay.userInfoDict[self.UUID] = [
            self.ip, self.port, "AraciName", "NEGOTIATOR", None
        ]
        with open('../Yayinci_Blogger/data.json', 'w') as fp:
            json.dump(yay.userInfoDict, fp)

        name = self.ui.username_field.text()
        request = "UINFO"
        myClient = yay.ClientThread("Client Thread", self.ip, self.port,
                                    request, self.logQueue)
        response = myClient.control()
        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")

    def change_profile_name(self):
        # kullanıcı adını bağlandığında otomatik olarak değiştirme
        username = self.ui.username_field.text()
        self.ui.UserNameLabel_field.setText(username)

    def share_twit_button(self):
        text = self.ui.Twit_field.toPlainText()
        request = text.strip()
        myClient = yay.ClientThread("Client Thread", self.UUIDtoConnect,
                                    self.ip, self.port, request, self.logQueue)
        response = myClient.control()

        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")
        '''
        # share butonu ile my blog içerisine twit paylaşımı burası degisecek
        text = self.ui.plainTextEdit_4.toPlainText()
        if len(my_blog_list)==0:
            notification = 'Henüz blog yazılmadı.'
            my_blog_list.append(notification)
            self.ui.listWidget_6.addItems(my_blog_list)
        else:
            my_blog_list.append(text)
            self.ui.listWidget_6.addItems(my_blog_list)
            # twit_list=[]
            # twit1=self.ui.plainTextEdit_4.toPlainText()
            # twit_list.append(twit1)
            # self.ui.listWidget_6.addItems(twit_list) 
        '''

    def suggest_user(self, number_of_suggest, userlist):
        # sayıya göre kullanıcı öneri listesini gösterme

        # self.number_of_suggest = number_of_suggest
        # self.userlist = userlist
        # if userlist is None:
        #    error_notification = 'Baglananan kullanıcı bulunmamaktadır.'
        #    self.ui.listWidget_6.addItems(error_notification)
        pass

    def run(self):
        self.show()
        self.qt_app.exec_()
Esempio n. 4
0
class ProjectUi(QtWidgets.QMainWindow):
    def __init__(self, logQueue):
        self.logQueue = logQueue

        self.qt_app = QtWidgets.QApplication(sys.argv)
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # list1 =[]
        self.ui.pushButton.pressed.connect(self.connect)
        # self.ui.pushButton.pressed.connect(self.get_host_with_port)
        self.ui.pushButton.pressed.connect(self.change_profile_name)
        # self.ui.pushButton.pressed.connect(self.disable_button)
        self.ui.pushButton_2.pressed.connect(self.logout_button)
        self.ui.pushButton_7.pressed.connect(self.subscribe_button)
        self.ui.pushButton_3.pressed.connect(self.unsubscribe_button)
        self.ui.pushButton_4.pressed.connect(self.unblock_button)
        self.ui.pushButton_6.pressed.connect(self.block_button)
        self.ui.pushButton_9.pressed.connect(self.send_message_button)
        self.ui.pushButton_5.pressed.connect(self.share_twit_button)
        self.initializeIpPort()

        #self.list =QtWidgets.QListWidget(self)

    def initializeIpPort(self):
        self.ui.lineEdit.setText("127.0.0.1")
        self.ui.lineEdit_2.setText("12342")
        self.ui.lineEdit_3.setText("Mustafa")

    def connect(self):
        self.get_host_with_port()
        pass

    def refresh_feed_button(self):
        # takip edilen kişilerin serverlarına istek atarak twitleri yeniler
        pass

    def send_message_button(self):
        # Send message to followed içine yazılan text yalnızca
        # followers içinde check edilen kişilere gönderilecektir
        pass

    def block_button(self):
        # Followers içindeki kullanıcılardan check edilenleri engelleyecektir.
        pass

    def unblock_button(self):
        # Blocked içindeki kullanıcılardan check edilenlerin engellerini kaldıracaktır.
        pass

    def unsubscribe_button(self):
        # Followed içindeki kullanıcılardan check edilenleri takipten çıkacaktır.
        pass

    def subscribe_button(self):
        # Suggested users içindeki kullanıcılardan check edilenleri takip edecektir.
        pass

    def logout_button(self):
        # logout ui kapatma olarak tasarlanmıştır. ileride connection close olarak değiştirilebilir
        # self.close()
        request = "PBKEY:" + "BUNUIMZALA"
        myClient = ar.ClientThread("Client Thread", self.ip, self.port,
                                   request, self.logQueue)
        response = myClient.control()

    def disable_button(self):
        self.ui.pushButton.setDisabled(True)

    def get_host_with_port(self):
        # ip ve port alma işlemi
        self.ip = self.ui.lineEdit.text()
        self.port = self.ui.lineEdit_2.text()
        name = self.ui.lineEdit_3.text()

        request = "UINFO"
        myClient = ar.ClientThread("Client Thread", self.ip, self.port,
                                   request, self.logQueue)
        response = myClient.control()

        self.ui.listWidget.addItem("XXX" + response + "XXX")

        #self.ui.plainTextEdit_4.setPlainText(i)

        # for i in range(10):
        #    self.ui.listWidget.addItem('Item %s' %(i+1))

        #item = QtGui.QListWidgetItem()
        # item = QtWidgets.QListWidgetItem0
        # item.setText(QtGui.QGuiApplication.translate("Dialog",'x',None,))
        # item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
        # item.setCheckState(QtCore.Qt.Unchecked)
        # self.listWidget.addItem(item)

    def change_profile_name(self):
        # kullanıcı adını bağlandığında otomatik olarak değiştirme
        username = self.ui.lineEdit_3.text()
        self.ui.label_2.setText(username)

    def share_twit_button(self):
        text = self.ui.plainTextEdit_4.toPlainText()
        request = text.strip()
        myClient = ar.ClientThread("Client Thread", self.ip, self.port,
                                   request, self.logQueue)
        response = myClient.control()

        self.ui.listWidget.addItem("XXX" + response + "XXX")

        pass
        '''
        # share butonu ile my blog içerisine twit paylaşımı burası degisecek
        text = self.ui.plainTextEdit_4.toPlainText()
        if len(my_blog_list)==0:
            notification = 'Henüz blog yazılmadı.'
            my_blog_list.append(notification)
            self.ui.listWidget_6.addItems(my_blog_list)
        else:
            my_blog_list.append(text)
            self.ui.listWidget_6.addItems(my_blog_list)
            # twit_list=[]
            # twit1=self.ui.plainTextEdit_4.toPlainText()
            # twit_list.append(twit1)
            # self.ui.listWidget_6.addItems(twit_list) 
        '''

    def suggest_user(self, number_of_suggest, userlist):
        # sayıya göre kullanıcı öneri listesini gösterme

        # self.number_of_suggest = number_of_suggest
        # self.userlist = userlist
        # if userlist is None:
        #    error_notification = 'Baglananan kullanıcı bulunmamaktadır.'
        #    self.ui.listWidget_6.addItems(error_notification)
        pass

    def run(self):
        self.show()
        self.qt_app.exec_()
Esempio n. 5
0
class ProjectUi(QtWidgets.QMainWindow):
    def __init__(self, logQueue):
        self.logQueue = logQueue

        self.qt_app = QtWidgets.QApplication(sys.argv)
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # list1 =[]
        self.ui.connect_button.pressed.connect(self.connect)
        # self.ui.connect_button.pressed.connect(self.get_host_with_port)
        self.ui.connect_button.pressed.connect(self.change_profile_name)
        # self.ui.connect_button.pressed.connect(self.disable_button)
        self.ui.LogOut_button.pressed.connect(self.logout_button)
        self.ui.Subscribe_button.pressed.connect(self.subscribe_button)
        self.ui.UnSubscribe_button.pressed.connect(self.unsubscribe_button)
        self.ui.UnBlock_button.pressed.connect(self.unblock_button)
        self.ui.Block_button.pressed.connect(self.block_button)
        self.ui.SendMessage_button.pressed.connect(self.send_message_button)
        self.ui.Share_button.pressed.connect(self.share_twit_button)
        self.ui.Pubkey_button.pressed.connect(self.pubkey_button)
        self.initializeIpPort()
        self.initializeMyBlogsList()

        #self.list =QtWidgets.QListWidget(self)

    def initializeIpPort(self):
        self.ui.ip_field.setText(str(yay.SERVER_HOST_2))
        self.ui.port_field.setText(str(yay.SERVER_PORT2))
        self.ui.username_field.setText("Orhan")
        #self.UUIDtoConnect=uuid.uuid4()

    def initializeMyBlogsList(self):
        try:
            f_myBlogs = open('Mb.txt', 'r')
            if f_myBlogs is None:
                print("Error: Can not open f_myBlogs\n")
            else:
                print("Dosya acildi\n")
                for line in f_myBlogs:
                    yay.my_blog_list.append(line)
            f_myBlogs.close()

            for item in yay.my_blog_list:
                self.ui.MyBlogList_field.addItem(item)
        except FileNotFoundError:
            pass

    def connect(self):
        self.get_host_with_port()
        pass

    def pubkey_button(self):
        # pubkey buttonuna basıldığında gerçekleştirilecek eylem
        request = "PBKEY:" + "BUNUIMZALA"
        # myClient = yay.ClientThread("Client Thread", self.UUIDtoConnect ,self.ip, self.port, request, self.logQueue)
        myClient = yay.ClientThread("Client Thread", self.ip, self.port,
                                    request, self.logQueue)
        response = myClient.control()
        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")

    def refresh_feed_button(self):
        # takip edilen kişilerin serverlarına istek atarak twitleri yeniler
        if (yay.BLOG == 1):
            self.ui.Feeds_field.addItem(yay.my_mainpage)

    def send_message_button(self):
        # Send message to followed içine yazılan text yalnızca
        # followers içinde check edilen kişilere gönderilecektir
        pass

    def block_button(self):
        # Followers içindeki kullanıcılardan check edilenleri engelleyecektir.
        pass

    def unblock_button(self):
        # Blocked içindeki kullanıcılardan check edilenlerin engellerini kaldıracaktır.
        pass

    def unsubscribe_button(self):
        # Followed içindeki kullanıcılardan check edilenleri takipten çıkacaktır.
        pass

    def subscribe_button(self):
        # Suggested users içindeki kullanıcılardan check edilenleri takip edecektir.
        pass

    def logout_button(self):
        # logout ui kapatma olarak tasarlanmıştır. ileride connection close olarak değiştirilebilir
        self.close()

    def disable_button(self):
        self.ui.connect_button.setDisabled(True)

    def get_host_with_port(self):
        # ip ve port alma işlemi
        self.ip = self.ui.ip_field.text()
        self.port = self.ui.port_field.text()
        self.UUID = "AraciUUID"
        yay.userInfoDict[self.UUID] = [
            self.ip, self.port, "AraciName", "NEGOTIATOR", None
        ]
        with open('../Yayinci_Blogger/data.json', 'w') as fp:
            json.dump(yay.userInfoDict, fp)

        name = self.ui.username_field.text()
        request = "UINFO"
        myClient = yay.ClientThread("Client Thread", self.ip, self.port,
                                    request, self.logQueue)
        response = myClient.control()
        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")

    def sendMyBlog(self):
        request = "SBLOG:" + self.ui.username_field.text(
        ) + ": " + self.ui.Twit_field.toPlainText() + "\n"
        myClient = yay.ClientThread("Client Thread", self.ip, self.port,
                                    request, self.logQueue)
        response = myClient.control()
        self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")

    def change_profile_name(self):
        # kullanıcı adını bağlandığında otomatik olarak değiştirme
        username = self.ui.username_field.text()
        self.ui.UserNameLabel_field.setText(username)

    def share_twit_button(self):
        myBlog = self.ui.Twit_field.toPlainText() + "\n"
        yay.my_blog_list.append(myBlog)
        self.sendMyBlog()
        f_myBlogs = open("Mb.txt", 'a')
        f_myBlogs.write(myBlog)
        f_myBlogs.close()
        self.ui.MyBlogList_field.addItem(myBlog)
        self.ui.Twit_field.clear()

        #text = self.ui.Twit_field.toPlainText()
        #request = text.strip()
        #myClient = yay.ClientThread("Client Thread", self.ip, self.port, request, self.logQueue)
        #response = myClient.control()
        #self.ui.SuggestedUser_field.addItem("XXX" + response + "XXX")

    def suggest_user(self, number_of_suggest, userlist):
        # sayıya göre kullanıcı öneri listesini gösterme

        # self.number_of_suggest = number_of_suggest
        # self.userlist = userlist
        # if userlist is None:
        #    error_notification = 'Baglananan kullanıcı bulunmamaktadır.'
        #    self.ui.listWidget_6.addItems(error_notification)
        pass

    def run(self):
        self.show()
        self.qt_app.exec_()