JDMainWin::JDMainWin(const QString &name, const QString &jid, int acc, QWidget *p) : QDialog(p, Qt::Window) , model_(0) , commands_(0) , refreshInProgres_(false) , yourJid_(name) { setAttribute(Qt::WA_DeleteOnClose); ui_.setupUi(this); setWindowTitle(tr("Jabber Disk - %1").arg(name)); model_ = new JDModel(jid, this); ui_.lv_disk->setModel(model_); commands_ = new JDCommands(acc, jid, this); ui_.pb_send->setShortcut(QKeySequence("Ctrl+Return")); connect(commands_, SIGNAL(incomingMessage(QString,JDCommands::Command)), SLOT(incomingMessage(QString,JDCommands::Command))); connect(commands_, SIGNAL(outgoingMessage(QString)), SLOT(outgoingMessage(QString))); connect(ui_.pb_refresh, SIGNAL(clicked()), SLOT(refresh())); connect(ui_.pb_send, SIGNAL(clicked()), SLOT(doSend())); connect(ui_.pb_clear, SIGNAL(clicked()), SLOT(clearLog())); connect(ui_.lv_disk, SIGNAL(newIndex(QModelIndex)), SLOT(indexChanged(QModelIndex))); connect(ui_.lv_disk, SIGNAL(contextMenu(QModelIndex)), SLOT(indexContextMenu(QModelIndex))); connect(model_, SIGNAL(moveItem(QString,QString)), SLOT(moveItem(QString,QString))); show(); QTimer::singleShot(0, this, SLOT(refresh())); }
void ConnectionGateKeeper::validate() { DEBUG("Validation connection -> sending ping"); QJsonObject json; json["command"] = "Ping"; QJsonDocument jsonDoc(json); emit outgoingMessage(_d->connectionId, jsonDoc.toJson()); _d->timer.start(); }
void JDCommands::sendStanza(const QString &text, Command c) { emit outgoingMessage(text); lastCommand_ = c; QString id; jdc->sendStanza(account_, jid_, text, &id); timer_->start(); eventLoop_->exec(); }
void Udp::parseOSC() { //Parse all UDP datagram while(socket->hasPendingDatagrams()) { //Extract host, port & UDP datagram QHostAddress receivedHost; quint16 receivedPort; parsingBufferISize = socket->readDatagram((char*)parsingBufferI, 4096, &receivedHost, &receivedPort); quint16 indexBuffer = 0; //Parse UDP content while(indexBuffer < parsingBufferISize) { parsingIndexAddressBuffer = 0; parsingIndexArgumentsBuffer = 0; //Looking for '/' while((indexBuffer < parsingBufferISize) && (parsingBufferI[indexBuffer] != '/')) indexBuffer++; //Parse header if((parsingBufferI[indexBuffer] == '/') && (parsingBufferISize%4 == 0)) { //OSC Adress while((indexBuffer < parsingBufferISize) && (parsingBufferI[indexBuffer] != 0)) parsingAddressBuffer[parsingIndexAddressBuffer++] = parsingBufferI[indexBuffer++]; parsingAddressBuffer[parsingIndexAddressBuffer] = 0; //Looking for ',' while((indexBuffer < parsingBufferISize) && (parsingBufferI[indexBuffer++] != ',')) {} //OSC arguments type indexBuffer--; while((indexBuffer < parsingBufferISize) && (parsingBufferI[++indexBuffer] != 0)) parsingArgumentsBuffer[parsingIndexArgumentsBuffer++] = parsingBufferI[indexBuffer]; parsingArgumentsBuffer[parsingIndexArgumentsBuffer] = 0; indexBuffer++; //Index modulo 4 while((indexBuffer < parsingBufferISize) && ((indexBuffer++)%4 != 0)) {} indexBuffer--; //Parse content QString commandDestination = QString(parsingAddressBuffer); QString command = commandDestination + " "; QList<QVariant> commandArguments; quint16 indexDataBuffer = 0; while((indexBuffer < parsingBufferISize) && (indexDataBuffer < parsingIndexArgumentsBuffer)) { //Integer argument if(parsingArgumentsBuffer[indexDataBuffer] == 'i') { union { int i; char ch[4]; } u; u.ch[3] = parsingBufferI[indexBuffer + 0]; u.ch[2] = parsingBufferI[indexBuffer + 1]; u.ch[1] = parsingBufferI[indexBuffer + 2]; u.ch[0] = parsingBufferI[indexBuffer + 3]; indexBuffer += 4; QString commandValue = QString::number(u.i); command += commandValue + " "; commandArguments << u.i; } //Float argument else if(parsingArgumentsBuffer[indexDataBuffer] == 'f') { union { float f; char ch[4]; } u; u.ch[3] = parsingBufferI[indexBuffer + 0]; u.ch[2] = parsingBufferI[indexBuffer + 1]; u.ch[1] = parsingBufferI[indexBuffer + 2]; u.ch[0] = parsingBufferI[indexBuffer + 3]; indexBuffer += 4; QString commandValue = QString::number(u.f); command += commandValue + " "; commandArguments << u.f; } //String argument else if(parsingArgumentsBuffer[indexDataBuffer] == 's') { QString commandValue = ""; while((indexBuffer < parsingBufferISize) && (parsingBufferI[indexBuffer]) != 0) commandValue += parsingBufferI[indexBuffer++]; indexBuffer++; while(indexBuffer % 4 != 0) indexBuffer++; command += commandValue + " "; commandArguments << commandValue; } else indexBuffer += 4; indexDataBuffer++; } //Fire events (log, message and script mapping) emit(outgoingMessage(receivedHost.toString(), receivedPort, commandDestination.toLower(), commandArguments)); } } } }
void Skype::skypeMessage(const QString &message) { kdDebug(14311) << k_funcinfo << endl;//some debug info QString messageType = message.section(' ', 0, 0).stripWhiteSpace().upper();//get the first part of the message if (messageType == "CONNSTATUS") {//the connection status QString value = message.section(' ', 1, 1).stripWhiteSpace().upper();//get the second part of the message if (value == "OFFLINE") d->connStatus = csOffline; else if (value == "CONNECTING") d->connStatus = csConnecting; else if (value == "PAUSING") d->connStatus = csPausing; else if (value == "ONLINE") d->connStatus = csOnline; else if (value == "LOGGEDOUT") d->connStatus = csLoggedOut; resetStatus();//set new status } else if (messageType == "USERSTATUS") {//Status of this user QString value = message.section(' ', 1, 1).stripWhiteSpace().upper();//get the second part if (value == "UNKNOWN") d->onlineStatus = usUnknown; else if (value == "OFFLINE") d->onlineStatus = usOffline; else if (value == "ONLINE") d->onlineStatus = usOnline; else if (value == "SKYPEME") d->onlineStatus = usSkypeMe; else if (value == "AWAY") d->onlineStatus = usAway; else if (value == "NA") d->onlineStatus = usNA; else if (value == "DND") d->onlineStatus = usDND; else if (value == "INVISIBLE") d->onlineStatus = usInvisible; resetStatus(); } else if (messageType == "USERS") {//some user info QString theRest = message.section(' ', 1).stripWhiteSpace();//take the rest if (d->searchFor == "FRIENDS") {//it was initial search for al users QStringList names = QStringList::split(",", theRest);//divide it into names by comas kdDebug(14311) << "Names: " << names << endl;//write what you have done with that for (QStringList::iterator it = names.begin(); it != names.end(); ++it) {//run trough the names QString name = (*it).stripWhiteSpace();//get the name only if (name.isEmpty()) continue;//just skip the empty names emit newUser(name);//add the user to list } if (d->scanForUnread) search("MISSEDMESSAGES"); } } else if (messageType == "USER") {//This is for some contact const QString &contactId = message.section(' ', 1, 1);//take the second part, it is the user name const QString &type = message.section(' ', 2, 2).stripWhiteSpace().upper();//get what it is if ((type == "FULLNAME") || (type == "DISPLAYNAME") || (type == "SEX") || (type == "PHONE_HOME") || (type == "PHONE_OFFICE") || (type == "PHONE_MOBILE") || (type == "ONLINESTATUS") || (type == "BUDDYSTATUS") || (type == "HOMEPAGE")) { const QString &info = message.section(' ', 2);//and the rest is just the message for that contact emit contactInfo(contactId, info);//and let the contact know } else kdDebug(14311) << "Unknown message for contact, ignored" << endl; } else if (messageType == "CHATMESSAGE") {//something with message, maebe incoming/sent QString messageId = message.section(' ', 1, 1).stripWhiteSpace();//get the second part of message - it is the message ID QString type = message.section(' ', 2, 2).stripWhiteSpace().upper();//This part significates what about the message are we talking about (status, body, etc..) QString chatMessageType = (d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper(); if (chatMessageType == "ADDEDMEMBERS") { QString status = message.section(' ', 3, 3).stripWhiteSpace().upper(); if (d->recvMessages.find(messageId) != d->recvMessages.end()) return; d->recvMessages << messageId; const QString &users = (d->connection % QString("GET CHATMESSAGE %1 USERS").arg(messageId)).section(' ', 3).stripWhiteSpace(); QStringList splitUsers = QStringList::split(' ', users); const QString &chatId = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace(); for (QStringList::iterator it = splitUsers.begin(); it != splitUsers.end(); ++it) { if ((*it).upper() == getMyself().upper()) continue; emit joinUser(chatId, *it); } return; } else if (chatMessageType == "LEFT") { QString status = message.section(' ', 3, 3).stripWhiteSpace().upper(); if (d->recvMessages.find(messageId) != d->recvMessages.end()) return; d->recvMessages << messageId; const QString &chatId = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace(); const QString &chatType = (d->connection % QString("GET CHAT %1 STATUS").arg(chatId)).section(' ', 3, 3).stripWhiteSpace().upper(); if ((chatType == "DIALOG") || (chatType == "LEGACY_DIALOG")) return; const QString &user = (d->connection % QString("GET CHATMESSAGE %1 FROM_HANDLE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace(); const QString &reason = (d->connection % QString("GET CHATMESSAGE %1 LEAVEREASON").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper(); QString showReason = i18n("Unknown"); if (reason == "USER_NOT_FOUND") { showReason = i18n("User not found"); } else if (reason == "USER_INCAPABLE") { showReason = i18n("Does not have multi-user chat capability"); } else if ((reason == "ADDER_MUST_BE_FRIEND") || ("ADDER_MUST_BE_AUTHORIZED")) { showReason = i18n("Chat denied"); } else if (reason == "UNSUBSCRIBE") { showReason = ""; } if (user.upper() == getMyself().upper()) return; emit leftUser(chatId, user, showReason); return; } if (type == "STATUS") {//OK, status of some message has changed, check what is it QString value = message.section(' ', 3, 3).stripWhiteSpace().upper();//get the last part, what status it is if (value == "RECEIVED") {//OK, received new message, possibly read it if (chatMessageType == "SAID") {//OK, it is some IM hitchHike(messageId);//receive the message } } else if (value == "SENDING") { if ((d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper() == "SAID") { emit gotMessageId(messageId); } } else if (value == "SENT") {//Sendign out some message, that means it is a new one if ((d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper() == "SAID")//it is some message I'm interested in emit gotMessageId(messageId);//Someone may be interested in its ID if (d->recvMessages.find(messageId) != d->recvMessages.end()) return;//we already got this one d->recvMessages << messageId; const QString &chat = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace(); const QString &body = (d->connection % QString("GET CHATMESSAGE %1 BODY").arg(messageId)).section(' ', 3); if (!body.isEmpty())//sometimes skype shows empty messages, just ignore them emit outgoingMessage(body, chat); } } } else if (messageType == "CHATMESSAGES") { if (d->searchFor == "MISSEDMESSAGES") {//Theese are messages we did not read yet QStringList messages = QStringList::split(' ', message.section(' ', 1));//get the meassage IDs for (QStringList::iterator it = messages.begin(); it != messages.end(); ++it) { QString Id = (*it).stripWhiteSpace(); if (Id.isEmpty()) continue; skypeMessage(QString("CHATMESSAGE %1 STATUS RECEIVED").arg(Id));//simulate incoming message notification } } } else if (messageType == "CALL") { const QString &callId = message.section(' ', 1, 1).stripWhiteSpace(); if (message.section(' ', 2, 2).stripWhiteSpace().upper() == "CONF_ID") { if (d->knownCalls.findIndex(callId) == -1) {//new call d->knownCalls << callId; const QString &userId = (d->connection % QString("GET CALL %1 PARTNER_HANDLE").arg(callId)).section(' ', 3, 3).stripWhiteSpace(); emit newCall(callId, userId); } const QString &confId = message.section(' ', 3, 3).stripWhiteSpace().upper(); if (confId != "0") {//It is an conference emit groupCall(callId, confId); } } if (message.section(' ', 2, 2).stripWhiteSpace().upper() == "STATUS") { if (d->knownCalls.findIndex(callId) == -1) {//new call d->knownCalls << callId; const QString &userId = (d->connection % QString("GET CALL %1 PARTNER_HANDLE").arg(callId)).section(' ', 3, 3).stripWhiteSpace(); emit newCall(callId, userId); } const QString &status = message.section(' ', 3, 3).stripWhiteSpace().upper(); if (status == "FAILED") { int reason = (d->connection % QString("GET CALL %1 FAILUREREASON").arg(callId)).section(' ', 3, 3).stripWhiteSpace().toInt(); QString errorText = i18n("Unknown error"); switch (reason) { case 1: errorText = i18n("Misc error"); break; case 2: errorText = i18n("User or phone number does not exist"); break; case 3: errorText = i18n("User is offline"); break; case 4: errorText = i18n("No proxy found"); break; case 5: errorText = i18n("Session terminated"); break; case 6: errorText = i18n("No common codec found"); break; case 7: errorText = i18n("Sound I/O error"); break; case 8: errorText = i18n("Problem with remote sound device"); break; case 9: errorText = i18n("Call blocked by recipient"); break; case 10: errorText = i18n("Recipient not a friend"); break; case 11: errorText = i18n("User not authorized by recipient"); break; case 12: errorText = i18n("Sound recording error"); break; } emit callError(callId, errorText); } emit callStatus(callId, status); } } else if (messageType == "CURRENTUSERHANDLE") { QString user = message.section(' ', 1, 1).stripWhiteSpace(); QString name = (d->connection % QString("GET USER %1 DISPLAYNAME").arg(user)).section(' ', 3).stripWhiteSpace(); if (name.isEmpty()) name = (d->connection % QString("GET USER %1 FULLNAME").arg(user)).section(' ', 3).stripWhiteSpace(); if (name.isEmpty()) name = user; emit setMyselfName(name); } }
void JDCommands::sendStanzaDirect(const QString &text) { emit outgoingMessage(text); QString id; jdc->sendStanza(account_, jid_, text, &id); }
int IProcessMQ::Send(const std::string& message) { zmq::message_t outgoingMessage(message.size()); memcpy(outgoingMessage.data(), message.c_str(), message.size()); m_socket->send(outgoingMessage); return 0; }
Rekall::Rekall(const QStringList &arguments, QWidget *parent) : QDialog(parent) { trayIconWorking = false; trayIconIndex = 0; trayIconIndexOld = 9999; Global::rekall = this; qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); //Update updateManager = 0; forceUpdate = false; firstTimeOpened = newVersionOfRekall = false; if(arguments.contains("-forceupdate")) forceUpdate = true; //Tray icon trayTimer.setInterval(500); connect(&trayTimer, SIGNAL(timeout()), SLOT(trayIconToOnPrivate())); connect(&trayTimerOff, SIGNAL(timeout()), SLOT(trayIconToOffPrivate())); QString prefix = "mac"; #ifdef Q_OS_WIN prefix = "win"; #endif for(quint16 i = 0 ; i <= 17 ; i++) trayIcons << QIcon(QString(":/icons/rekall-menubar-%1-%2.png").arg(prefix).arg(i, 2, 10, QChar('0'))); trayIcon = new QSystemTrayIcon(this); trayIconToOffPrivate(); trayTimer.start(); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); //Interfaces Global::userInfos = new UserInfos(this); Global::http = new Http(this); Analyse *analyse = new Analyse(this); Global::analyse = analyse; connect(analyse, SIGNAL(trayChanged(QString,bool)), SLOT(analyseTrayChanged(QString,bool))); connect(analyse, SIGNAL(trayIconToOff()), SLOT(trayIconToOff())); connect(analyse, SIGNAL(trayIconToOn(qint16)), SLOT(trayIconToOn(qint16))); //Wrapper web Global::userInfos->setDockIcon(this, false); Global::webWrapper = new WebWrapper(); /* VideoPlayer *player = new VideoPlayer(); player->open(QUrl::fromLocalFile("/Users/guillaume/Documents/Rekall/Walden/Captations/captation WALDEN_TPV.mov")); player->seek(4000); */ trayMenu = new QMenu(this); trayMenu->setSeparatorsCollapsible(true); trayAnalyse = trayMenu->addAction(tr("File analysis…")); trayAnalysePause = trayMenu->addAction(tr("Pause analysis")); trayAnalysePause->setCheckable(true); connect(trayAnalysePause, SIGNAL(toggled(bool)), SLOT(trayAnalysePaused())); trayMenu->addSeparator(); trayMenu->addAction(tr("Open welcome page"), this, SLOT(openWebPage())); trayMenu->addAction(tr("Open welcome page in webrowser"), this, SLOT(openWebPageInBrowser())); //trayMenu->addAction(tr("Create a new project"), this, SLOT(addProject())); trayMenu->addSeparator(); trayMenuProjects = trayMenu->addAction(tr("Quit Rekall"), this, SLOT(closeRekall())); trayIcon->setContextMenu(trayMenu); trayIcon->show(); trayIconToOnPrivate(); QSettings settings; quint16 projectCount = settings.beginReadArray("projects"); /* if(projectCount == 0) { addProject(new Project("walden", "Walden", true, QFileInfo("/Users/guillaume/Documents/Rekall/Walden"), this)); addProject(new Project("joris-test", "Joris", false, QFileInfo("/Users/guillaume/Documents/Rekall/joris-test"), this)); } */ connect(Global::udp, SIGNAL(outgoingMessage(QString,quint16,QString,QList<QVariant>)), SLOT(incomingMessage(QString,quint16,QString,QList<QVariant>))); for(quint16 projectIndex = 0 ; projectIndex < projectCount ; projectIndex++) { settings.setArrayIndex(projectIndex); Project *project = new Project(settings.value("name").toString(), settings.value("friendlyName").toString(), true, QFileInfo(settings.value("path").toString()), this); addProject(project); } settings.endArray(); //foreach(ProjectInterface *project, Global::projects) // project->load(); //Global settings creation if needed globalSettings = new QSettings(); if((globalSettings) && ((!globalSettings->childKeys().contains("id")) || (arguments.contains("-newuser")))) { firstTimeOpened = true; qsrand(QDateTime::currentDateTime().toTime_t()); updateAnonymousId = QString::number(qrand()); globalSettings->setValue("id", updateAnonymousId); globalSettings->setValue("version", ""); globalSettings->setValue("updatePeriod", 1); globalSettings->setValue("lastUpdate", QDateTime(QDate(2000, 01, 01))); } //Update management if((globalSettings) && (globalSettings->childKeys().contains("id"))) { QDateTime updateLastDate = globalSettings->value("lastUpdate") .toDateTime(); quint16 updatePeriod = globalSettings->value("updatePeriod").toUInt(); updateAnonymousId = globalSettings->value("id") .toString(); QString applicationVersionSettings = globalSettings->value("version").toString(); if(applicationVersionSettings != QCoreApplication::applicationVersion()) { globalSettings->setValue("version", QCoreApplication::applicationVersion()); firstTimeOpened = true; } qDebug("Last update : %s (should update each %d day(s))", qPrintable(updateLastDate.toString("dd/MM/yyyy hh:mm:ss")), updatePeriod); if((updateLastDate.daysTo(QDateTime::currentDateTime()) >= updatePeriod) || (forceUpdate)) checkForUpdates(); } askScreenshot = askAddProject = 0; startTimer(50); if(firstTimeOpened) showMessage(tr("Welcome!\nRekall is now running!")); else showMessage(tr("Rekall is now running!")); if(!arguments.contains("-silent")) openWebPage(); /* QWebView *webView = new QWebView(); webView->load(QUrl("http://127.0.0.1:23411")); webView->show(); */ }