void TerminalMessageDialog::initDialog() { if(globaldb.open()) { if(!dbisconnected) { dbisconnected = true; raao->setAppEnable(true); } QSqlQuery query(globaldb); query.prepare("SELECT name,IP FROM terminal"); query.exec(); while(query.next()) { ui->targetmonitor_combobox->addItem(query.value(0).toString(),query.value(1)); } query.clear(); query.finish(); //globaldb.close(); } else { if(dbisconnected) { dbisconnected = false; raao->setAppEnable(false); QMessageBox::warning(0,"警告","数据库连接失败!","确定"); } } //读取监视机IP配置等信息 connect(ui->addmonitor_toolbutton,SIGNAL(clicked()),this,SLOT(onAddMonitor())); connect(ui->removemonitor_toolbutton,SIGNAL(clicked()),this,SLOT(onRemoveMonitor())); connect(ui->sent_pushbutton,SIGNAL(clicked()),this,SLOT(onSendMessage())); connect(ui->editmessage_plaintextedit,SIGNAL(textChanged()),this,SLOT(onTextChanged())); }
void startFlushProcess() { int status, sendStatus = 0, recvStatus = 0; boolean breakFl = FALSE; while (!breakFl) { sendStatus = 0; recvStatus = 0; recvStatus = processIncomingMessage(); if (recvStatus == SOCKET_ERROR) { onHandleSocketError(recvStatus); break; } onChangeStatus(WAITING); status = syncInterface.onTryConsumerEntry(CONSUMER_WAIT_SECONDS * 1000); if (status == WAIT_OBJECT_0) { onChangeStatus(ACCUMULATING); MSG_LOCATION_ID id = syncInterface.onStartConsume(); int totalMsg, totalMsgSize; char* msg; boolean pending = TRUE; onChangeStatus(NORMAL); while (pending) { pending = msgStore.retrieveMsg(id, &totalMsg, &totalMsgSize, &msg); if (totalMsg > 0) { sendStatus = onSendMessage(&msg, &totalMsgSize); free(msg); if (sendStatus == SOCKET_ERROR) { onHandleSocketError(sendStatus); breakFl = TRUE; break; } } } } } }
int onCleanSocket(int status) { if (status > LISTENING) { int size = getChars(AGENT_EXIT) + 1; char* msgStr = (void*)allocateMemory(size); memset(msgStr, 0x0, size); sprintf(msgStr, "%d", AGENT_EXIT); onSendMessage(&msgStr, &size); // Introduce helper methods and it is to be moved there int err = closesocket(clientSocket); if (err == SOCKET_ERROR) return CLIENT_SOCKET_CLEANUP; } if (status > IDLE) { int err = closesocket(listenSocket); if (err == SOCKET_ERROR) return LISTEN_SOCKET_CLEANUP; } return NONE; }
ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const PeerData *peer) : TWidget(0), _profile(profile), _scroll(scroll), _peer(App::peer(peer->id)), _peerUser(_peer->chat ? 0 : _peer->asUser()), _peerChat(_peer->chat ? _peer->asChat() : 0), _hist(App::history(peer->id)), _chatAdmin(_peerChat ? (_peerChat->admin == MTP::authedId()) : false), // profile _nameCache(peer->name), _uploadPhoto(this, lang(lng_profile_set_group_photo), st::btnShareContact), _addParticipant(this, lang(lng_profile_add_participant), st::btnShareContact), _sendMessage(this, lang(lng_profile_send_message), st::btnShareContact), _shareContact(this, lang(lng_profile_share_contact), st::btnShareContact), _cancelPhoto(this, lang(lng_cancel)), a_photo(0), _photoOver(false), // settings _enableNotifications(this, lang(lng_profile_enable_notifications)), _clearHistory(this, lang(lng_profile_clear_history)), // shared media _allMediaTypes(false), _mediaShowAll(this, lang(lng_profile_show_all_types)), _mediaPhotos(this, QString()), _mediaVideos(this, QString()), _mediaDocuments(this, QString()), _mediaAudios(this, QString()), // participants _pHeight(st::profileListPhotoSize + st::profileListPadding.height() * 2), _kickWidth(st::linkFont->m.width(lang(lng_profile_kick))), _selectedRow(-1), _lastPreload(0), _contactId(0), _kickOver(0), _kickDown(0), _kickConfirm(0), _loadingId(0), _menu(0) { if (_peerUser) { _phoneText = _peerUser->phone.isEmpty() ? QString() : App::formatPhone(_peerUser->phone); _loadingId = MTP::send(MTPusers_GetFullUser(_peerUser->inputUser), rpcDone(&ProfileInner::gotFullUser)); } else if (_peerChat->photoId) { PhotoData *ph = App::photo(_peerChat->photoId); if (ph->date) { _photoLink = TextLinkPtr(new PhotoLink(ph, _peer)); } } else { _loadingId = MTP::send(MTPmessages_GetFullChat(App::peerToMTP(_peerChat->id).c_peerChat().vchat_id), rpcDone(&ProfileInner::gotFullChat)); } // profile _nameText.setText(st::profileNameFont, _nameCache, _textNameOptions); connect(&_uploadPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhoto())); connect(&_addParticipant, SIGNAL(clicked()), this, SLOT(onAddParticipant())); connect(&_sendMessage, SIGNAL(clicked()), this, SLOT(onSendMessage())); connect(&_shareContact, SIGNAL(clicked()), this, SLOT(onShareContact())); connect(&_cancelPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhotoCancel())); connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUpdateDone(PeerId))); connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUpdateFail(PeerId))); connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *))); connect(App::main(), SIGNAL(peerUpdated(PeerData *)), this, SLOT(peerUpdated(PeerData *))); connect(App::main(), SIGNAL(peerNameChanged(PeerData *, const PeerData::Names &, const PeerData::NameFirstChars &)), this, SLOT(peerUpdated(PeerData *))); // settings connect(&_enableNotifications, SIGNAL(clicked()), this, SLOT(onEnableNotifications())); connect(&_clearHistory, SIGNAL(clicked()), this, SLOT(onClearHistory())); // shared media connect(&_mediaShowAll, SIGNAL(clicked()), this, SLOT(onMediaShowAll())); connect(&_mediaPhotos, SIGNAL(clicked()), this, SLOT(onMediaPhotos())); connect(&_mediaVideos, SIGNAL(clicked()), this, SLOT(onMediaVideos())); connect(&_mediaDocuments, SIGNAL(clicked()), this, SLOT(onMediaDocuments())); connect(&_mediaAudios, SIGNAL(clicked()), this, SLOT(onMediaAudios())); _mediaLinks[OverviewPhotos] = &_mediaPhotos; _mediaLinks[OverviewVideos] = &_mediaVideos; _mediaLinks[OverviewDocuments] = &_mediaDocuments; _mediaLinks[OverviewAudios] = &_mediaAudios; App::main()->preloadOverviews(_peer); App::contextItem(0); resizeEvent(0); showAll(); }
MainPage::MainPage(QWidget* parent) : QWidget(parent) , search_widget_(new SearchWidget(8, false, this)) , contact_dialog_(new ContactDialog(this)) , video_window_(new VideoWindow()) , video_panel_(new CallPanelMain(this)) , pages_(new WidgetsNavigator(this)) , search_contacts_(nullptr) , profile_settings_(new ProfileSettingsWidget(this)) , general_settings_(new GeneralSettingsWidget(this)) , noContactsYetSuggestions_(nullptr) , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, NULL)) , add_contact_menu_(0) { connect(&Utils::InterConnector::instance(), SIGNAL(showNoContactsYetSuggestions()), this, SLOT(showNoContactsYetSuggestions())); connect(&Utils::InterConnector::instance(), SIGNAL(hideNoContactsYetSuggestions()), this, SLOT(hideNoContactsYetSuggestions())); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_page")); this->resize(400, 300); this->setProperty("Invisible", QVariant(true)); horizontal_layout_ = new QHBoxLayout(this); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); QMetaObject::connectSlotsByName(this); QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout()); QVBoxLayout* contactsLayout = new QVBoxLayout(); contactsLayout->setContentsMargins(0, 0, 0, 0); contactsLayout->setSpacing(0); assert(video_panel_); if (video_panel_) { contactsLayout->addWidget(video_panel_); video_panel_->hide(); } contactsLayout->addWidget(search_widget_); contactsLayout->addWidget(contact_list_widget_); QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); contactsLayout->addSpacerItem(contactsLayoutSpacer); pages_layout_ = new QVBoxLayout(); pages_layout_->setContentsMargins(0, 0, 0, 0); pages_layout_->setSpacing(0); pages_layout_->addWidget(pages_); { auto pc = pages_->count(); pages_->addWidget(contact_dialog_); pages_->addWidget(profile_settings_); pages_->addWidget(general_settings_); if (!pc) pages_->push(contact_dialog_); } originalLayout->addLayout(contactsLayout); originalLayout->addLayout(pages_layout_); QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); originalLayout->addSpacerItem(originalLayoutSpacer); originalLayout->setAlignment(Qt::AlignLeft); setFocus(); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), pages_, SLOT(poproot()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(nonActiveButtonPressed()), this, SLOT(addButtonClicked()), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection); connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection); search_widget_->setVisible(!contact_list_widget_->shouldHideSearch()); }
QtUdpSocketPlugin::QtUdpSocketPlugin() : _socket(nullptr), _helperReceiveCallback(), _checkerReceiveCallback(), _messageCounter(0), _conditionLock(), _conditionVariable(), _targetHost(), _targetPort(0) { QObject::connect(this, SIGNAL(doListen(quint16)), this, SLOT(onListen(quint16))); QObject::connect(this, SIGNAL(doConnect(QString, quint16)), this, SLOT(onConnect(QString, quint16))); QObject::connect(this, SIGNAL(doSendMessage(QString)), this, SLOT(onSendMessage(QString))); QObject::connect(this, SIGNAL(doDisconnect()), this, SLOT(onDisconnect())); }
MainPage::MainPage(QWidget* parent) : QWidget(parent) , search_widget_(new SearchWidget(false, this)) , contact_dialog_(new ContactDialog(this)) #ifndef STRIP_VOIP , video_window_(nullptr) #else , video_window_(nullptr) #endif //STRIP_VOIP , pages_(new WidgetsNavigator(this)) , search_contacts_(nullptr) , profile_settings_(new ProfileSettingsWidget(this)) , general_settings_(new GeneralSettingsWidget(this)) , live_chats_page_(new LiveChatHome(this)) , themes_settings_(new ThemesSettingsWidget(this)) , noContactsYetSuggestions_(nullptr) , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, nullptr)) , add_contact_menu_(nullptr) , settings_timer_(new QTimer(this)) , introduceYourselfSuggestions_(nullptr) , needShowIntroduceYourself_(false) , liveChats_(new LiveChats(this)) , login_new_user_(false) , recv_my_info_(false) { connect(&Utils::InterConnector::instance(), &Utils::InterConnector::showPlaceholder, this, &MainPage::showPlaceholder); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_page")); setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true)); this->resize(400, 300); this->setProperty("Invisible", QVariant(true)); horizontal_layout_ = new QHBoxLayout(this); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); QMetaObject::connectSlotsByName(this); QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout()); QVBoxLayout* contactsLayout = new QVBoxLayout(); contactsLayout->setContentsMargins(0, 0, 0, 0); contactsLayout->setSpacing(0); contactsLayout->addWidget(search_widget_); contactsLayout->addWidget(contact_list_widget_); QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); contactsLayout->addSpacerItem(contactsLayoutSpacer); pages_layout_ = new QVBoxLayout(); pages_layout_->setContentsMargins(0, 0, 0, 0); pages_layout_->setSpacing(0); pages_layout_->addWidget(pages_); { auto pc = pages_->count(); pages_->addWidget(contact_dialog_); pages_->addWidget(profile_settings_); pages_->addWidget(general_settings_); pages_->addWidget(live_chats_page_); pages_->addWidget(themes_settings_); if (!pc) pages_->push(contact_dialog_); } originalLayout->addLayout(contactsLayout); originalLayout->addLayout(pages_layout_); QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); originalLayout->addSpacerItem(originalLayoutSpacer); originalLayout->setAlignment(Qt::AlignLeft); setFocus(); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsShow(bool,QString)), this, SLOT(onThemesSettingsShow(bool,QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(liveChatsShow()), this, SLOT(onLiveChatsShow()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(attachPhoneBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(attachUinBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), this, SLOT(popPagesToRoot()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection); connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection); search_widget_->setVisible(!contact_list_widget_->shouldHideSearch()); post_stats_with_settings(); QObject::connect(settings_timer_, SIGNAL(timeout()), this, SLOT(post_stats_with_settings())); settings_timer_->start(Ui::period_for_stats_settings_ms); connect(Ui::GetDispatcher(), &core_dispatcher::myInfo, this, &MainPage::myInfo, Qt::UniqueConnection); connect(Ui::GetDispatcher(), &core_dispatcher::login_new_user, this, &MainPage::loginNewUser, Qt::DirectConnection); add_contact_menu_ = new FlatMenu(search_widget_->searchEditIcon()); Utils::ApplyStyle(add_contact_menu_, "QMenu { background-color: #f2f2f2; border:1px solid #cccccc; } " "QMenu::item { padding-left:40dip; background-color:transparent; color:black; padding-top:6dip; padding-bottom:6dip; padding-right:12dip; } " "QMenu::item:selected { background-color:#e2e2e2; } " "QMenu::icon { padding-left:22dip; }" ); add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newchat_100.png")), QT_TRANSLATE_NOOP("contact_list", "New chat"), contact_list_widget_, SLOT(allClicked())); add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newgroup_100.png")), QT_TRANSLATE_NOOP("contact_list", "Create Groupchat"), this, SLOT(createGroupChat())); add_contact_menu_->setExpandDirection(Qt::AlignLeft); add_contact_menu_->stickToIcon(); Utils::ApplyStyle(search_widget_->searchEditIcon(), "QPushButton::menu-indicator { image:none; } QPushButton:pressed { background-color:transparent; }"); search_widget_->searchEditIcon()->setMenu(add_contact_menu_); }