void Lobby::on_addtofav_released() { ui->addtofav->setStyleSheet(get_stylesheet_path("addtofav.png")); //you cant add favorites from favorites m8 if (!public_servers_selected) return; //this means there is no selection if (int_selected_server == -1) return; server_type fav_server = m_server_list.at(int_selected_server); if (!favoritefile.open(QIODevice::WriteOnly | QIODevice::Append)) { callError("failed to write in \"favorites.txt\""); } QTextStream out(&favoritefile); QString str_port = QString::number(fav_server.port); QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name; out << server_line << '\n'; //favoritefile.write(server_line); favoritefile.close(); }
int main(int argc, char *argv[]) { int pNum, cNum, sleepTime, i, ret; pthread_t p_thread[NUM]; pthread_t c_thread[NUM]; //input error if(argc != 4) { printf("error input!\n"); exit(-1); } //read from the command line sleepTime = atoi(argv[1]); pNum = atoi(argv[2]); cNum = atoi(argv[3]); //semaphore initialization sem_init(&empty, 0, BUFFER_SIZE); sem_init(&full, 0, 0); sem_init(&mutex, 0, 1); //create pthreads for(i = 0; i < pNum; ++i) { pOrder[i] = 1 + i; ret = pthread_create(&p_thread[i], NULL, producer, &pOrder[i]); if(ret != 0) callError(); } for(i = 0; i < cNum; ++i) { cOrder[i] = 1 + i; ret = pthread_create(&c_thread[i], NULL, consumer, &cOrder[i]); if(ret != 0) callError(); } sleep(sleepTime); return 0; }
mpkgErrorReturn waitResponce(mpkgErrorCode errCode) { return callError(errCode); }
void charicon::released() { callError("ohai"); m_parent->hide(); }
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 Lobby::LoadFavorites() { if (fileExists((getBasePath() + "favorites.txt"), true)) favoritefile.setFileName(getBasePath() + "favorites.txt"); //legacy support, the new name is favorites.txt else if (fileExists((getBasePath() + "serverlist.txt"), true)) favoritefile.setFileName(getBasePath() + "serverlist.txt"); else { callError("could not find \"favorites.txt\" "); return; } if (!favoritefile.open(QIODevice::ReadOnly)) { callError("failed to read \"favorites.txt\""); } QTextStream in(&favoritefile); QVector<server_type> temp_servers; for(int line_count{0}; ; ++line_count) { if (in.atEnd()) break; QString line = in.readLine(); QStringList line_contents = line.split(":"); //we check if the line is valid first if (line_contents.size() == 3) { server_type serv; serv.name = line_contents.at(2); serv.ip = line_contents.at(0); serv.port = line_contents.at(1).toInt(); temp_servers.insert(line_count, serv); favoriteservers = temp_servers; //favoriteservers.insert(line_count, serv); } else { //QString str_line = QString::number(line_count + 1); //bad servers already show up as !MISCONFIGURED! we dont need this dumb error >:v( //callError("favorites.txt appears to be misconfigured on line " + str_line + ". Expected <ip>:<port>:<name> format."); server_type serv; serv.name = "!MISCONFIGURED!"; serv.ip = ""; serv.port = 0; temp_servers.insert(line_count, serv); favoriteservers = temp_servers; } if (in.atEnd()) break; } favoritefile.close(); }
/*--------------------------------------------------------------------------*/ int C2F(inittypenames)() { int ierr = 0; int i = 0; /* initialize COMMON (struct) */ C2F(typnams).ptmax = 1; for (i = 0; i < MAX_SCILAB_DEFINED_TYPE; i++) { C2F(typnams).tp[i] = i; C2F(typnams).ln[i] = 0; C2F(typnams).ptr[i] = 0; } /* add types */ ierr = addNamedType("s", sci_matrix); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("p", sci_poly); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("b", sci_boolean); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("sp", sci_sparse); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("spb", sci_boolean_sparse); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("msp", sci_matlab_sparse); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("i", sci_ints); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("h", sci_handles); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("c", sci_strings); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("m", sci_u_function); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("mc", sci_c_function); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("f", sci_lib); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("l", sci_list); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("tl", sci_tlist); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("ml", sci_mlist); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("ptr", sci_lufact_pointer); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("ip", sci_implicit_poly); if (ierr) { callError(ierr); return 1; } ierr = addNamedType("fptr", sci_intrinsic_function); if (ierr) { callError(ierr); return 1; } return 0; }