Esempio n. 1
0
SingleWindow::~SingleWindow()
{
	KaduWindow *kadu = m_kaduWindowService->kaduWindow();
	bool visible = isVisible();

	m_configuration->deprecatedApi()->writeEntry("SingleWindow", "KaduWindowWidth", kadu->width());

	disconnect(m_chatWidgetManager, 0, this, 0);
	disconnect(m_tabs, 0, this, 0);
	disconnect(kadu, 0, this, 0);

	if (!m_sessionService->isClosing())
	{
		for (int i = m_tabs->count()-1; i >= 0; --i)
		{
			ChatWidget *chatWidget = static_cast<ChatWidget *>(m_tabs->widget(i));
			const Chat &chat = chatWidget->chat();
			m_tabs->removeTab(i);
			delete chatWidget;
			m_chatWidgetManager->openChat(chat, OpenChatActivation::DoNotActivate);
		}
	}

	kadu->setParent(0);
	if (!m_sessionService->isClosing())
		kadu->setVisible(visible);
}
Esempio n. 2
0
void PluginGUIHandler::ReceivedVoipData(const QString& peer_id) 
{
        std::cerr << "****** Plugin GUI handler: received VoipData!" << std::endl;

	std::vector<RsVoipDataChunk> chunks ;

	if(!rsVoip->getIncomingData(peer_id.toStdString(),chunks))
	{
		std::cerr << "PluginGUIHandler::ReceivedVoipData(): No data chunks to get. Weird!" << std::endl;
		return ;
	}

	ChatDialog *di = ChatDialog::getExistingChat(peer_id.toStdString()) ;
	if (di) {
		ChatWidget *cw = di->getChatWidget();
		if (cw) {
			const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();

			foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) {
				AudioChatWidgetHolder *acwh = dynamic_cast<AudioChatWidgetHolder*>(chatWidgetHolder) ;

				if (acwh) {
					for (unsigned int i = 0; i < chunks.size(); ++i) {
						for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++){
							QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);
							acwh->addAudioData(peer_id,&qb);
						}
					}
					break;
				}
			}
		}
	} else {
Esempio n. 3
0
void ChatDialog::addToParent(QWidget *newParent)
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->addToParent(newParent);
	}
}
Esempio n. 4
0
void ChatDialog::removeFromParent(QWidget *oldParent)
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->removeFromParent(oldParent);
	}
}
Esempio n. 5
0
void ChatDialog::focusDialog()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->focusDialog();
	}
}
Esempio n. 6
0
TalkableProxyModel * ChatEditBox::talkableProxyModel()
{
	ChatWidget *cw = chatWidget();
	if (cw && cw->chat().contacts().count() > 1)
		return cw->talkableProxyModel();

	return 0;
}
Esempio n. 7
0
QString ChatDialog::getTitle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getTitle();
	}

	return "";
}
Esempio n. 8
0
bool ChatDialog::setStyle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->setStyle();
	}

	return false;
}
Esempio n. 9
0
int ChatDialog::getPeerStatus()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getPeerStatus();
	}

	return 0;
}
Esempio n. 10
0
bool ChatDialog::hasNewMessages()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->hasNewMessages();
	}

	return false;
}
Esempio n. 11
0
bool ChatDialog::isTyping()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->isTyping();
	}

	return false;
}
Esempio n. 12
0
const RSStyle *ChatDialog::getStyle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getStyle();
	}

	return NULL;
}
Esempio n. 13
0
void SingleWindow::onkaduKeyPressed(QKeyEvent *e)
{
	/* unfortunatelly does not work correctly */
	if (HotKey::shortCut(m_configuration, e, "ShortCuts", "FocusOnRosterTab"))
	{
		ChatWidget *chatWidget = static_cast<ChatWidget *>(m_tabs->currentWidget());
		if (chatWidget)
			chatWidget->edit()->setFocus();
	}
}
Esempio n. 14
0
void ChatDialog::init(const std::string &peerId, const QString &title)
{
	this->peerId = peerId;

	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->init(peerId, title);

		connect(cw, SIGNAL(infoChanged(ChatWidget*)), this, SLOT(chatInfoChanged(ChatWidget*)));
		connect(cw, SIGNAL(newMessage(ChatWidget*)), this, SLOT(chatNewMessage(ChatWidget*)));
	}
}
void BitSharesMainWindow::on_actionCreateMail_triggered()
{
    //QMessageBox::information(this,"Create Mail Message","Widget not implemented yet");
    //Allow multiple createMailWidgets to be created
    //QCreateMailWidget* createMailWidget = new QCreateMailWidget(this);
    //createMailWidget->show();
    ChatWidget* chatWidget = new ChatWidget(nullptr); //parent is nullptr to make modeless floating window
    static int person = 0;
    ++person;
    QString contactName = QString("Person %1").arg(person);
    chatWidget->setContact(contactName);
    chatWidget->show();

}
Esempio n. 16
0
File: tabs.cpp Progetto: vogel/kadu
void TabsManager::onTabChange(int index)
{
    if (index < 0)
        return;

    ChatWidget *chatWidget = static_cast<ChatWidget *>(TabDialog->widget(index));
    Title->setActiveChatWidget(chatWidget);

    const Chat &chat = chatWidget->chat();
    if (chat.unreadMessagesCount() > 0)
        emit chatWidgetActivated(chatWidget);

    //TabDialog->setWindowTitle(chatWidget->title()->title());
    //TabDialog->setWindowIcon(chatWidget->title()->icon());

    chatWidget->edit()->setFocus();
}
Esempio n. 17
0
void ShowHistoryAction::showDaysMessages(QAction *action, int days)
{
	Action *act = qobject_cast<Action *>(action);
	Chat actionChat = act ? act->context()->chat() : Chat::null;

	ChatWidget *chatWidget = action->data().value<ChatWidget *>();
	if (!chatWidget)
	{
		m_historyWindowService->show(actionChat);
		return;
	}

	WebkitMessagesView *chatMessagesView = chatWidget->chatMessagesView();
	if (!chatMessagesView)
	{
		m_historyWindowService->show(actionChat);
		return;
	}

	chatMessagesView->setForcePruneDisabled(0 != days);

	if (-1 == days)
	{
		m_historyWindowService->show(chatWidget->chat());
		return;
	}

	const Chat &buddyChat = m_buddyChatManager->buddyChat(chatWidget->chat());
	const Chat &messagesChat = buddyChat ? buddyChat : chatWidget->chat();
	HistoryStorage *historyStorage = m_history->currentStorage();

	if (!historyStorage)
		return;

	HistoryQuery query;
	query.setTalkable(messagesChat);

	if (0 == days)
		query.setLimit(configuration()->deprecatedApi()->readUnsignedNumEntry("History", "ChatHistoryCitation", 10));
	else
		query.setFromDate(QDate::currentDate().addDays(-days));

	new HistoryMessagesPrepender(historyStorage->messages(query), chatMessagesView);
}
Esempio n. 18
0
void VOIPGUIHandler::ReceivedInvitation(const RsPeerId &peer_id, int flags)
{
#ifdef VOIPGUIHANDLER_DEBUG
	std::cerr << "****** VOIPGUIHandler: received Invitation from peer " << peer_id.toStdString() << " with flags==" << flags << std::endl;
#endif
	ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
	if (di) {
		ChatWidget *cw = di->getChatWidget();
		if(cw) {
			const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();

			foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList)
			{
				VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;

				if (acwh)
					acwh->ReceivedInvitation(peer_id, flags);
			}
		}
	} else {
Esempio n. 19
0
void VOIPGUIHandler::ReceivedVoipData(const RsPeerId &peer_id)
{
	std::vector<RsVOIPDataChunk> chunks ;

	if(!rsVOIP->getIncomingData(peer_id,chunks))
	{
		std::cerr << "VOIPGUIHandler::ReceivedVoipData(): No data chunks to get. Weird!" << std::endl;
		return ;
	}

	ChatDialog *di = ChatDialog::getChat(ChatId(peer_id), Settings->getChatFlags());
	if (di) {
		ChatWidget *cw = di->getChatWidget();
		if (cw) {
			const QList<ChatWidgetHolder*> &chatWidgetHolderList = cw->chatWidgetHolderList();

			foreach (ChatWidgetHolder *chatWidgetHolder, chatWidgetHolderList) 
			{
				VOIPChatWidgetHolder *acwh = dynamic_cast<VOIPChatWidgetHolder*>(chatWidgetHolder) ;

				if (acwh) {
						for (unsigned int chunkIndex=0; chunkIndex<chunks.size(); chunkIndex++)
						{
							QByteArray qb(reinterpret_cast<const char *>(chunks[chunkIndex].data),chunks[chunkIndex].size);

							if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_AUDIO)
							acwh->addAudioData(peer_id, &qb);
							else if(chunks[chunkIndex].type == RsVOIPDataChunk::RS_VOIP_DATA_TYPE_VIDEO)
							acwh->addVideoData(peer_id, &qb);
							else
								std::cerr << "VOIPGUIHandler: Unknown data type received. type=" << chunks[chunkIndex].type << std::endl;
						}
					break;
				}
			}
		}
	} else {
Esempio n. 20
0
void NotifyQt::UpdateGUI()
{
	if(RsAutoUpdatePage::eventsLocked())
		return ;

	{
		QMutexLocker m(&_mutex) ;
		if(!_enabled)
			return ;
	}

	static bool already_updated = false ;	// these only update once at start because they may already have been set before 
														// the gui is running, then they get updated by callbacks.
	if(!already_updated)
	{
		emit messagesChanged() ;
		emit neighboursChanged();
		emit configChanged();

		already_updated = true ;
	}
	
	/* Finally Check for PopupMessages / System Error Messages */

	if (rsNotify)
	{
		uint32_t sysid;
		uint32_t type;
        std::string title, id, msg;

		/* You can set timeToShow, timeToLive and timeToHide or can leave the standard */
		ToasterItem *toaster = NULL;
		if (rsNotify->NotifyPopupMessage(type, id, title, msg))
		{
			uint popupflags = Settings->getNotifyFlags();

			switch(type)
			{
				case RS_POPUP_ENCRYPTED_MSG:
					SoundManager::play(SOUND_MESSAGE_ARRIVED);

					if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
					{
						toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message"))));
					}
					break;
				case RS_POPUP_MSG:
					SoundManager::play(SOUND_MESSAGE_ARRIVED);

					if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
					{
						toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
					}
					break;
				case RS_POPUP_CONNECT:
					SoundManager::play(SOUND_USER_ONLINE);

					if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
					{
						toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
					}
					break;
				case RS_POPUP_DOWNLOAD:
					SoundManager::play(SOUND_DOWNLOAD_COMPLETE);

					if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
					{
						/* id = file hash */
						toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
					}
					break;
				case RS_POPUP_CHAT:
					if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster)
					{
                        // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT
                        ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id)));
						ChatWidget *chatWidget;
						if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
							// do not show when active
							break;
						}
                        toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
					}
					break;
				case RS_POPUP_GROUPCHAT:
					if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster)
					{
						MainWindow *mainWindow = MainWindow::getInstance();
						if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) {
							if (MainWindow::getActivatePage() == MainWindow::Friends) {
								if (FriendsDialog::isGroupChatActive()) {
									// do not show when active
									break;
								}
							}
						}
						toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
					}
					break;
				case RS_POPUP_CHATLOBBY:
					if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster)
					{
                        ChatId chat_id(id);

                        ChatDialog *chatDialog = ChatDialog::getChat(chat_id);
						ChatWidget *chatWidget;
                        if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
                            // do not show when active
                            break;
                        }
                        ChatLobbyDialog *chatLobbyDialog = dynamic_cast<ChatLobbyDialog*>(chatDialog);

						RsGxsId sender(title);
						if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender))
                            break; // participant is muted

                        toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str())));
					}
					break;
				case RS_POPUP_CONNECT_ATTEMPT:
					if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster)
					{
						// id = gpgid
						// title = ssl name
						// msg = peer id
						toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
					}
					break;
			}
		}

		/*Now check Plugins*/
		if (!toaster) {
			int pluginCount = rsPlugins->nbPlugins();
			for (int i = 0; i < pluginCount; ++i) {
				RsPlugin *rsPlugin = rsPlugins->plugin(i);
				if (rsPlugin) {
					ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify();
					if (toasterNotify) {
						toaster = toasterNotify->toasterItem();
						continue;
					}
				}
			}
		}

		if (toaster) {
			/* init attributes */
			toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);

			/* add toaster to waiting list */
			//QMutexLocker lock(&waitingToasterMutex);
			waitingToasterList.push_back(toaster);
		}

		if (rsNotify->NotifySysMessage(sysid, type, title, msg))
		{
			/* make a warning message */
			switch(type)
			{
				case RS_SYS_ERROR:
					QMessageBox::critical(MainWindow::getInstance(),
							QString::fromUtf8(title.c_str()),
							QString::fromUtf8(msg.c_str()));
					break;
				case RS_SYS_WARNING:
					QMessageBox::warning(MainWindow::getInstance(),
							QString::fromUtf8(title.c_str()),
							QString::fromUtf8(msg.c_str()));
					break;
				default:
				case RS_SYS_INFO:
					QMessageBox::information(MainWindow::getInstance(),
							QString::fromUtf8(title.c_str()),
							QString::fromUtf8(msg.c_str()));
					break;
			}
		}

		if (rsNotify->NotifyLogMessage(sysid, type, title, msg))
		{
			/* make a log message */
			std::string logMesString = title + " " + msg;
			switch(type)
			{
				case RS_SYS_ERROR:
				case RS_SYS_WARNING:
				case RS_SYS_INFO:
					emit logInfoChanged(QString::fromUtf8(logMesString.c_str()));
			}
		}
	}

	/* Now start the waiting toasters */
	startWaitingToasters();
}
Esempio n. 21
0
void ChatDialog::setPeerStatus(uint32_t status)
{
	ChatWidget *cw = getChatWidget();
	if (cw) 
		cw->updateStatus(QString::fromStdString(getPeerId()), status);
}
Esempio n. 22
0
void MainClientWindow::AddMessageToChannel(IRCData::MessageData *messageData)
{
    ChatWidget *widget = GetChannel(messageData->channelName);
    widget->AddMessage(messageData);
}
Esempio n. 23
0
static void do_finish_chat_input(void * arg){
    ChatWidget * widget = (ChatWidget *) arg;
    widget->endChatLine();
}
Esempio n. 24
0
ChatWidget* Protocol::createConsoleWidget()
{
    ChatWidget* console = new ChatWidget;
    console->setConsoleMode(true);
    return console;
}