void Jabber::LoggedIn() { LOG("Jabber", liDebug, "Jabber::LoggedIn()"); Progress("Jabber Login", "Jabber: Logged in!", 1.00); BMessage msg(IM::MESSAGE); msg.AddInt32("im_what", IM::STATUS_SET); msg.AddString("protocol", kProtocolName); msg.AddString("status", ONLINE_TEXT); fServerMsgr.SendMessage( &msg ); fFullLogged=true; LOG("Jabber", liDebug, "Starting fLaterBuddyList"); while (fLaterBuddyList->size() != 0) { BString id = *(fLaterBuddyList->begin()); fLaterBuddyList->pop_front(); // removes first item JabberContact* contact=getContact(id.String()); if(!contact) { AddContact(id.String(),id.String(),""); BuddyStatusChanged(id.String(),OFFLINE_TEXT); } } LOG("Jabber", liDebug, "Ending fLaterBuddyList"); }
ContactList* ContactList::getSubsetExcluding(ContactList* excludeList) { int i, j; ContactList* newList = new ContactList(); for (i=0; i<getNumberContacts(); i++) { bool include = true; Contact* contact = getContact(i); for (j=0; j<excludeList->getNumberContacts(); j++) { if (*contact == *excludeList->getContact(j)) { include = false; break; } } // If this contact should be included, add it to the list. if (include) { newList->addContact(new Contact(*contact)); } } return newList; }
bool MySqlStorage::updateSubscriptionToContact(QString jid, QString contactJid, QString subscription) { if (!contactExists(jid, contactJid)) { Contact contact("", false, "", contactJid, "", subscription, QSet<QString>()); return addContactToRoster(jid, contact); } QString contactSubscription = getContact(jid, contactJid).getSubscription(); QSqlQuery query; query.prepare("UPDATE qjabberd_contact SET subscription = :subscription WHERE user_id = :user_id AND jid = :jid"); query.bindValue(":user_id", getUserId(jid)); query.bindValue(":jid", contactJid); if (((subscription == "from") && (contactSubscription == "to")) || ((subscription == "to") && (contactSubscription == "from"))) { query.bindValue(":subscription", "both"); } else { query.bindValue(":subscription", subscription); } return query.exec(); }
void Jabber::SendContactInfo(const char* id) { JabberContact *jid=getContact(id); if(!jid) return; BMessage msg(IM::MESSAGE); msg.AddInt32("im_what", IM::CONTACT_INFO); msg.AddString("protocol", kProtocolName); msg.AddString("id", id); msg.AddString("nick", jid->GetName()); // vCard information JabberVCard* vCard = jid->GetVCard(); if (vCard) { msg.AddString("full name", vCard->GetFullName()); msg.AddString("first name", vCard->GetGivenName()); msg.AddString("middle name", vCard->GetMiddleName()); msg.AddString("last name", vCard->GetFamilyName()); msg.AddString("email", vCard->GetEmail()); msg.AddString("birthday", vCard->GetBirthday()); msg.AddString("url", vCard->GetURL()); } // Send contact information fServerMsgr.SendMessage(&msg); }
void ScreenPhone::outgoingCall(pjsua_call_id &call_id, pjsua_call_info &call_info) { QString cinfo = QString(call_info.remote_info.ptr); cinfo = cinfo.mid(0, cinfo.indexOf("@")); cinfo = cinfo.mid(cinfo.indexOf(":")+1); controller->screenContacts->getContact(cinfo); QStringList contact = getContact(cinfo); if(this->active_channel()==1) { this->setC1_call_id(call_id); this->setC1_state("dialing"); this->setC1_sip_actiontext("Dialing to\n" + ((contact[0]==cinfo) ? "" : contact[0] + " ") + contact[4] + " " + cinfo ); } if(this->active_channel()==2) { this->setC2_call_id(call_id); this->setC2_state("dialing"); this->setC2_sip_actiontext("Dialing to\n" + ((contact[0]==cinfo) ? "" : contact[0] + " ") + contact[4] + " " + cinfo ); } controller->setQml("screens/phoneactive.qml", "phoneactive"); }
ChatUnit *IrcAccount::getUnit(const QString &name, bool create) { Q_UNUSED(create); if (name.startsWith('#') || name.startsWith('&')) return 0; return getContact(name, QString(), false); }
QContactManager::Error GContactsBackend::modifyContact(const QString &aID, QContact &aContact) { FUNCTION_CALL_TRACE; Q_ASSERT (iMgr); LOG_DEBUG("Modifying a Contact with ID" << aID); QContactManager::Error modificationStatus = QContactManager::UnspecifiedError; QContact oldContactData; getContact(QContactId::fromString(aID), oldContactData); aContact.setId(oldContactData.id()); oldContactData = aContact; bool modificationOk = iMgr->saveContact(&oldContactData); modificationStatus = iMgr->error(); if(!modificationOk) { // either contact exists or something wrong with one of the detailed definitions LOG_WARNING("Contact Modification Failed"); } // no else return modificationStatus; }
std::string Application::getNodeKeyClear(uint64_t userId) const { if (userId == currentUser().id()) { return currentUser().personalData().nodeKeyClear(); } return getContact(userId).relation().nodeKeyClear(currentUser()); }
void Jabber::Message(JabberMessage * message){ if(message->GetBody()!="") //we have something to tell GotMessage(message->GetFrom().String(),message->GetBody().String()); if(message->GetError()!="") //not a nice situation.. { Error(message->GetError().String(),message->GetFrom().String()); return; } LOG(kProtocolName, liHigh, "GETX: '%s'",message->GetX().String()) ; if(message->GetX().ICompare("composing") == 0) { //someone send a composing event. if(message->GetBody() == "") //Notification { LOG(kProtocolName, liHigh,"CONTACT_STARTED_TYPING"); BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::CONTACT_STARTED_TYPING); im_msg.AddString("protocol", kProtocolName); im_msg.AddString("id", message->GetFrom()); fServerMsgr.SendMessage(&im_msg); } else //Request { // where we put the last messge id? on the contact (is it the right place?) // maybe we should make an hash table? a BMesage.. JabberContact *contact=getContact(message->GetFrom().String()); if(contact) contact->SetLastMessageID(message->GetID()); } } else if(message->GetX().ICompare("jabber:x:event") == 0) { //not define event this maybe due to: // unkown event. // no event (means stop all) LOG(kProtocolName, liHigh,"CONTACT_STOPPED_TYPING"); BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::CONTACT_STOPPED_TYPING); im_msg.AddString("protocol", kProtocolName); im_msg.AddString("id", message->GetFrom()); fServerMsgr.SendMessage(&im_msg); } }
void PeopleInfoManager::addToContactList(const ContactInfo &contact) { if (getContact(contact.getUserId()) == NULL) { ContactInfo *newContact = new ContactInfo(); *newContact = contact; contactMap.insert(contact.getUserId(), newContact); saveContacts(); PIMDEBUG("PeopleInfoManager::contact added " << contact.getUserId()); emit contactListChanged(); } }
void GoogleTalk::SendContactInfo(const char* id) { JabberContact *jid=getContact(id); if(jid) { BMessage msg(IM::MESSAGE); msg.AddInt32("im_what", IM::CONTACT_INFO); msg.AddString("protocol", kProtocolName); msg.AddString("id", id); msg.AddString("nick", jid->GetName()); //just nick ?? fServerMsgr.SendMessage(&msg); } }
QContactManager::Error ContactsBackend::modifyContact(const QString &aID, const QString &aContact) { FUNCTION_CALL_TRACE; LOG_DEBUG("Modifying a Contact with ID" << aID); QContactManager::Error modificationStatus = QContactManager::UnspecifiedError; if (iMgr == NULL) { LOG_WARNING("Contacts backend not available"); } else { QContact oldContactData; #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) getContact(QContactId::fromString (aID), oldContactData); #else getContact(aID.toUInt(), oldContactData); #endif QStringList contactStringList; contactStringList.append(aContact); QContact newContactData = convertVCardListToQContactList(contactStringList).first(); newContactData.setId(oldContactData.id()); oldContactData = newContactData; bool modificationOk = iMgr->saveContact(&oldContactData); modificationStatus = iMgr->error(); if(!modificationOk) { // either contact exists or something wrong with one of the detailed definitions LOG_WARNING("Contact Modification Failed"); } // no else } return modificationStatus; }
bool MySqlStorage::updateAskAttributeToContact(QString jid, QString contactJid, QString ask) { Contact contact = getContact(jid, contactJid); QSqlQuery query; query.prepare("UPDATE qjabberd_contact SET ask = :ask WHERE user_id = :user_id AND jid = :jid"); query.bindValue(":user_id", getUserId(jid)); query.bindValue(":jid", contactJid); if ((contact.getSubscription() != "to") && (contact.getSubscription() != "both")) { query.bindValue(":ask", ask); } return query.exec(); }
void Jabber::SendBuddyIcon(const char* id) { JabberContact* jid = getContact(id); if (!jid) return; // vCard information JabberVCard* vCard = jid->GetVCard(); if (vCard) { BString data = vCard->GetPhotoContent(); BMessage msg(IM::MESSAGE); msg.AddInt32("im_what", IM::SET_BUDDY_ICON); msg.AddString("protocol", kProtocolName); msg.AddString("id", id); msg.AddData("icondata", B_RAW_TYPE, data.String(), data.Length()); fServerMsgr.SendMessage(&msg); } }
/* * * Fonction de decodage d un message de detection de contact ** Si la nouvelle valeur est differente de l ancienne, elle est mise a jour, et celle-ci est reporte dans un fichier de log. ** Renvoie 0 si un changement de valeur a eu lieu, 1 sinon. */ int decodeMessageContact(char* message, struct Sensor * p_sensor) { int closed; closed = getContact(message); #if DEBUG > 0 if (closed == 1) { printf("Contact ferme. \n"); } else { printf("Contact ouvert. \n"); } #endif /* Si la nouvelle valeur est differente de l ancienne */ if (closed != p_sensor->value) { p_sensor->value = closed; printf("[ComponentInterface] Nouvelle valeur pour le capteur de contact, ID : %s; valeur : %f \n", p_sensor->id, p_sensor->value); gLogsLog(p_sensor->id, p_sensor->value); return VALUE_CHANGE; } return NO_CHANGE; }
ArrayElement* ToDo::clone() { ToDo* ret = new ToDo(); if (getClass()) ret->setClass(*classEvent); if (getCompleted()) ret->setCompleted(*completed); if (getCreated()) ret->setCreated(*created); if (getDescription()) ret->setDescription(*description); if (getDtStamp()) ret->setDtStamp(*dtStamp); if (getDtStart()) ret->setDtStart(*dtStart); if (getGeo()) ret->setGeo(*geo); if (getLastMod()) ret->setLastMod(*lastMod); if (getLocation()) ret->setLocation(*location); if (getOrganizer()) ret->setOrganizer(*organizer); if (getPercent()) ret->setPercent(*percent); if (getPriority()) ret->setPriority(*priority); if (getRecurID()) ret->setRecurID(*recurID); if (getSequence()) ret->setSequence(*seq); if (getStatus()) ret->setStatus(*status); if (getSummary()) ret->setSummary(*summary); if (getUid()) ret->setUid(*uid); if (getUrl()) ret->setUrl(*url); if (getDue()) ret->setDue(*due); if (getDuration()) ret->setDuration(*duration); if (getAttach()) ret->setAttach(*attach); if (getAttendee()) ret->setAttendee(*attendee); if (getCategories()) ret->setCategories(*categories); if (getComment()) ret->setComment(*comment); if (getContact()) ret->setContact(*contact); if (getExDate()) ret->setExDate(*exDate); if (getExRule()) ret->setExRule(*exRule); if (getRStatus()) ret->setRStatus(*rStatus); if (getRelated()) ret->setRelated(*related); if (getResources()) ret->setResources(*resources); if (getRDate()) ret->setRDate(*rDate); if (getRRule()) ret->setRRule(*rRule); if (getXProp()) ret->setXProp(*xProp); return ret; }
int main( int argc, char *argv[] ) { try { _2Real::app::Engine testEngine; auto loadedBundle = testEngine.loadBundle( "TestBundle_BasicBlocksAndCustomTypes" ); // -------print the block metainfo--------- auto bundleinfo = loadedBundle.second; std::cout << "basic bundle info" << std::endl; std::cout << "description " << bundleinfo.getDescription() << std::endl; std::cout << "category " << bundleinfo.getCategory() << std::endl; std::cout << "author " << bundleinfo.getAuthor() << std::endl; std::cout << "contact " << bundleinfo.getContact() << std::endl; std::cout << "version " << bundleinfo.getVersion() << std::endl; std::cout << std::endl; // i know that these are custom types, so no need for casting around auto typeinfos = bundleinfo.getExportedTypes(); std::cout << "number of exported types : " << typeinfos.size() << std::endl; if ( !typeinfos.empty() ) std::cout << "--------------------------------" << std::endl; for ( auto it : typeinfos ) { printCustomTypeMetainfo( it ); std::cout << "--------------------------------" << std::endl; } std::cout << std::endl; auto blockinfos = bundleinfo.getExportedBlocks(); std::cout << "exported blocks " << blockinfos.size() << std::endl; for ( auto it : blockinfos ) { std::cout << "\t" << it.getName() << std::endl; std::cout << "\t" << it.getDescription() << std::endl; auto dependencies = it.getDependenciesByName(); std::cout << "\tdependencies\t"; for ( auto it : dependencies ) std::cout << it << " "; std::cout << std::endl; std::vector< _2Real::app::InletMetainfo > inletinfos = it.getInlets(); std::cout << "\tinlets " << inletinfos.size() << std::endl; for ( auto it : inletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; std::cout << "\t\tis multi " << std::boolalpha << it.isMulti() << std::endl; } std::vector< _2Real::app::OutletMetainfo > outletinfos = it.getOutlets(); std::cout << "\toutlets " << outletinfos.size() << std::endl; for ( auto it : outletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } std::vector< _2Real::app::ParameterMetainfo > paraminfos = it.getParameters(); std::cout << "\tparameters " << paraminfos.size() << std::endl; for ( auto it : paraminfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } } // -------create block instances--------- auto bundle = loadedBundle.first; auto threadpool = testEngine.createThreadpool( _2Real::ThreadpoolPolicy::FIFO ); auto counter = loadedBundle.first.createBlock( "counter", threadpool, std::vector< _2Real::app::BlockHandle >() ); auto io = counter.getBlockIo(); auto counterinfo = bundleinfo.getExportedBlock( "counter" ); auto inc = std::static_pointer_cast< _2Real::app::InletHandle >( counter.getBlockIo().mInlets[ 0 ] ); auto incinfo = counterinfo.getInlet( "increment" ); auto stringy = std::static_pointer_cast< _2Real::app::InletHandle >( counter.getBlockIo().mInlets[ 1 ] ); auto stringyinfo = counterinfo.getInlet( "stringy" ); auto multiinlet = std::static_pointer_cast< _2Real::app::MultiInletHandle >( counter.getBlockIo().mInlets[ 2 ] ); auto multiinletinfo = counterinfo.getInlet( "multi" ); std::deque< _2Real::app::InletHandle > subinlets; auto info = incinfo.getTypeMetainfo(); auto custominfo = std::static_pointer_cast< _2Real::app::CustomTypeMetainfo >( info ); auto basicinfo = stringyinfo.getTypeMetainfo(); uint32_t aNumber = 0; auto aSimple = custominfo->makeCustomData(); aSimple.set( "uint_field", aNumber ); std::string aString = ""; auto policy = counter.getUpdatePolicy(); policy.set( _2Real::DefaultUpdatePolicy::ANY ); auto timer = testEngine.createTimer( 4.0 ); timer.start(); std::future< _2Real::BlockResult > setup = counter.setup(); handleFuture( setup ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; else if ( line == "test" ) { //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.appeqnd( " next" ); //stringy->setValue( aString ); for ( auto it : subinlets ) { std::shared_ptr< _2Real::DataItem > data( new _2Real::DataItem( ( uint32_t ) 10 ) ); it.setValue( data ); } std::this_thread::sleep_for( std::chrono::milliseconds( 200 ) ); //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.append( " next" ); //stringy->setValue( aString );q std::this_thread::sleep_for( std::chrono::milliseconds( 200 ) ); //aNumber += 1; //aSimple.set( "uint_field", aNumber ); //inc->setValue( aSimple ); //aString.append( " next" ); //stringy->setqValue( aString ); } else if ( line == "policy" ) { std::future< _2Real::BlockResult > start = counter.startUpdating(); handleFuture( start ); } else if ( line == "timer" ) { std::future< _2Real::BlockResult > start = counter.startUpdating( timer ); handleFuture( start ); } else if ( line == "done" ) { std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); } else if ( line == "add" ) { _2Real::app::InletHandle subinlet = multiinlet->add(); subinlets.push_back( subinlet ); } else if ( line == "del" ) { if ( !subinlets.empty() ) { multiinlet->remove( subinlets.back() ); subinlets.pop_back(); } } } std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); std::future< _2Real::BlockResult > shutdown = counter.shutdown(); handleFuture( shutdown ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } testEngine.clear(); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } } catch ( _2Real::Exception &e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << " " << e.message() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } catch ( std::exception const& e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } return 0; }
void MoodBoxServer::getContact(Callback callback, qint32 userId) { getContact(callback, QVariant(), userId); }
void FB::print() const { string AccountName; getContact(AccountName); cout << "Account Name: " << AccountName << "\nFaceBook Account: " << FBUser; }
status_t Jabber::Process( BMessage * msg ) { switch ( msg->what ) { case IM::MESSAGE: { int32 im_what = 0; msg->FindInt32("im_what", &im_what ); switch ( im_what ) { case IM::SET_STATUS: { const char *status = msg->FindString("status"); LOG(kProtocolName, liMedium, "Set status to %s", status); if (strcmp(status, OFFLINE_TEXT) == 0) { SetStatus(S_OFFLINE,OFFLINE_TEXT); //do the log-out? } else if (strcmp(status, AWAY_TEXT) == 0) { if(IsAuthorized()){ //const char *away_msg; BString away_msg; if(msg->FindString("away_msg",&away_msg) == B_OK) { // quick and dirty way to use advanced away status: // add 'DND: ' for Do not Disturb // or 'XA: ' for Extended Away if(away_msg.Compare("DND: ",4) == 0) SetStatus(S_DND,away_msg); else if(away_msg.Compare("XA: ",4) == 0) SetStatus(S_XA,away_msg); else SetStatus(S_AWAY,away_msg); } else SetStatus(S_AWAY,AWAY_TEXT); SetAway(true); } } else if (strcmp(status, ONLINE_TEXT) == 0) { if(!IsAuthorized()) { if(fUsername == "") Error("Empty Username!",NULL); if(fServer == "") Error("Empty Server!",NULL); if(fPassword == "") Error("Empty Password!",NULL); Progress("Jabber Login", "Jabber: Connecting..", 0.0); } SetStatus(S_ONLINE,ONLINE_TEXT); //do the login! if(IsAuthorized()) SetAway(false); } else { Error("Invalid",NULL); LOG(kProtocolName, liHigh, "Invalid status when setting status: '%s'", status); } } break; case IM::SEND_MESSAGE: { const char * buddy=msg->FindString("id"); const char * sms=msg->FindString("message"); JabberMessage jm; jm.SetTo(buddy); jm.SetFrom(GetJid()); jm.SetBody(sms); TimeStamp(jm); //not the right place.. see Jabber::Message JabberContact *contact=getContact(buddy); //tmp: new mess id! BString messid("imkit_"); messid << idsms; idsms++; if(contact) jm.SetID(messid); SendMessage(jm); MessageSent(buddy,sms); } break; case IM::REGISTER_CONTACTS: { //debugger("REGISTER"); type_code garbage; int32 count = 0; msg->GetInfo("id", &garbage, &count); if (count > 0 ) { for ( int i=0; msg->FindString("id",i); i++ ) { const char * id = msg->FindString("id",i); JabberContact* contact=getContact(id); if(contact) BuddyStatusChanged(contact); else { //Are we on-line? // send auth req? if(fFullLogged) { AddContact(id,id,""); BuddyStatusChanged(id,OFFLINE_TEXT); } else { // we add to a temp list. // when logged in we will register the new buddy.. fLaterBuddyList->push_back(BString(id)); } } }; } else return B_ERROR; } break; case IM::UNREGISTER_CONTACTS: { const char * buddy=NULL; for ( int i=0; msg->FindString("id", i, &buddy) == B_OK; i++ ) { LOG(kProtocolName, liDebug, "Unregister Contact: '%s'", buddy); if(!fFullLogged) BuddyStatusChanged(buddy,OFFLINE_TEXT); else { LOG(kProtocolName, liDebug, "Unregister Contact DOING IT"); JabberContact* contact=getContact(buddy); if(contact) RemoveContact(contact); } } } break; case IM::USER_STARTED_TYPING: { const char * id=NULL; if( msg->FindString("id", &id) == B_OK ) { JabberContact* contact=getContact(id); if(contact) StartComposingMessage(contact); } } break; case IM::USER_STOPPED_TYPING: { const char * id=NULL; if( msg->FindString("id", &id) == B_OK ) { JabberContact* contact=getContact(id); if(contact && (contact->GetLastMessageID().ICompare("")!=0)){ StopComposingMessage(contact); contact->SetLastMessageID(""); } } } break; case IM::GET_CONTACT_INFO: //debugger("Get Contact Info! ;)"); SendContactInfo(msg->FindString("id")); break; case IM::SEND_AUTH_ACK: { if(!IsAuthorized()) return B_ERROR; const char * id = msg->FindString("id"); int32 button = msg->FindInt32("which"); if (button == 0) { //Authorization granted AcceptSubscription(id); BMessage im_msg(IM::MESSAGE); im_msg.AddInt32("im_what", IM::CONTACT_AUTHORIZED); im_msg.AddString("protocol", kProtocolName); im_msg.AddString("id", id); im_msg.AddString("message", ""); fServerMsgr.SendMessage(&im_msg); //now we want to see you! ;) AddContact(id,id,""); } else { //Authorization rejected Error("Authorization rejected!",id); } } break; default: // we don't handle this im_what code msg->PrintToStream(); return B_ERROR; } } break; default: // we don't handle this what code return B_ERROR; } return B_OK; }
void PhoneMsg::print()const { string AccountName; getContact(AccountName); cout << "Account Name: " << AccountName << "\nPhone Number: " << PhoneNum; }
void Email::print()const { string AccountName; getContact(AccountName); cout << "Account Name: " << AccountName << "\nEmail Account: " << EmailAddress; }
int main(int argc, char** argv) { const int Sentinel = 0; //The value 0 Exits the program if entered by the user. int input = 1; //Variable 'input' is where the value entered by the user is stored. string name; //This value stores the name of a contact. //It is meant to be instantiated by the askName() function ContactList clientList; cout << "This program is designed to maintain contact information" << endl; while(input != Sentinel) //Loop structure. Loop will only exit when 0 is entered. { menu(); //display menu and choices cin >> input; //User inputs a choice. Choice is saved in 'input' //Perform appropriate operation pending on the input value. if(input == 1) { cout <<"(Add Contact)"<< endl; clientList.addToHead(getContact()); } else if(input == 2) { if(clientList.empty()) { cout <<"Error:Cannot delete from empty contact list" << endl; } else { cout <<"(Delete Contact)" << endl; name = askName(); if(clientList.verify(name)) {clientList.delete_ByName(name);} else{ cout << "Error:Contact '" << name << "' not found in the contact list" << endl;} } } else if(input == 3) if(clientList.empty()) { cout <<"Error:Cannot display empty contact list" << endl; } else{ cout << "(Display all Contacts)"<< endl; clientList.displayList(); } else if(input == 4) if(clientList.empty()) { cout <<"Error:Cannot display specific contact from empty contact list" << endl; } else{ cout <<"(Display Specific Contact)"<< endl; name = askName(); if(clientList.verify(name)) {clientList.get_ByName(name)->display();} else {cout << "Error: Contact '" << name << "' not found in the contact list" << endl;} } } return 0; }
string DecodedDataDocumentParser::replaceSocamPersonTags (string text) { regex_t regex; const char* tag_regex_text = "<\\s*person\\s*>([^,]*),([^<]*)<\\s*/person\\s*>"; compileRegex(®ex, tag_regex_text); size_t ngroups = regex.re_nsub + 1; regmatch_t *groups = (regmatch_t *) malloc(ngroups * sizeof(regmatch_t)); //string text(to_match); while (1) { const char * p = text.c_str(); int nomatch = regexec(®ex, p, ngroups, groups, 0); if (nomatch) { break; } regmatch_t match = groups[0]; if (groups[0].rm_so == -1) { break; } string name, surname; size_t nmatched; for (nmatched = 0; nmatched < ngroups; nmatched++) { if (groups[nmatched].rm_so == (size_t)(-1)) { break; } string matchStr = text.substr (groups[nmatched].rm_so,groups[nmatched].rm_eo-groups[nmatched].rm_so); cout << "Match: "<< matchStr << endl; if(nmatched == 1) { name = matchStr; } else if(nmatched == 2) { surname = matchStr; } } cout << "Parsed: name=" << name << " surname=" << surname << endl; string tag = text.substr (match.rm_so,match.rm_eo-match.rm_so); QContact contact = getContact(name, surname); //qWarning("\tContact ID: %d -- UUID: %s",contact.localId(),contact.details("Guid").at(0).value("Guid").toStdString().c_str()); //qWarning("\t\tDisplayLabel: %s",contact.details("DisplayLabel").at(0).value("Label").toStdString().c_str()); //qWarning("\t\tEmail %s",contact.details("EmailAddress").at(0).value("EmailAddress").toStdString().c_str()); //qWarning("\t\tPhoneNumber: %s",contact.details("PhoneNumber").at(0).value("PhoneNumber").toStdString().c_str()); /* QContactDetail(name="DisplayLabel", key=7, "Label"=QVariant(QString, "Self Simulator") ); QContactDetail(name="Type", key=10, "Type"=QVariant(QString, "Contact") ); QContactDetail(name="Name", key=13, "CustomLabel"=QVariant(QString, "Self Simulator") , "FirstName"=QVariant(QString, "Self") , "LastName"=QVariant(QString, "Simulator") ); QContactDetail(name="EmailAddress", key=16, "EmailAddress"=QVariant(QString, "*****@*****.**") ); QContactDetail(name="PhoneNumber", key=19, "PhoneNumber"=QVariant(QString, "+44123456789") ); QContactDetail(name="Address", key=22, "Country"=QVariant(QString, "UK") , "Locality"=QVariant(QString, "Leister") , "Street"=QVariant(QString, "56 Edmonton Square") ); QContactDetail(name="Guid", key=25, "Guid"=QVariant(QString, "0") ); QContactDetail(name="Timestamp", key=28, "CreationTimestamp"=QVariant(QDateTime, QDateTime("dom 13. mar 12:21:09 2011") ) , "ModificationTimestamp"=QVariant(QDateTime, QDateTime("dom 13. mar 12:21:09 2011") ) ); */ ostringstream oss ; oss << "<table>"; oss << "<tr>"; if(contact.details("DisplayLabel").count()>0) { oss << "<td>" << contact.details("DisplayLabel").at(0).value("Label").toStdString() << "</td>"; } oss << "</tr>"; oss << "<tr>"; if(contact.details("EmailAddress").count()>0) { oss << "<td>" << contact.details("EmailAddress").at(0).value("EmailAddress").toStdString() << "</td>"; } oss << "</tr>"; oss << "<tr>"; if(contact.details("PhoneNumber").count()>0) { oss << "<td>" << contact.details("PhoneNumber").at(0).value("PhoneNumber").toStdString() << "</td>"; } oss << "</tr>"; oss << "</table>"; string newTagContent = oss.str(); text.replace(match.rm_so,match.rm_eo-match.rm_so,newTagContent); cout<<"Replaced:" <<text<<endl; } regfree (®ex); return text; }
AuthorizationState::AuthorizationStateEnum PeopleInfoManager::getContactAuthorization(qint32 id) const { const ContactInfo *user = getContact(id); return (user != NULL) ? user->getAuthorizationState() : AuthorizationState::Undefined; }
QString PeopleInfoManager::getContactMotto(qint32 id) const { const ContactInfo *user = getContact(id); return (user != NULL) ? user->getMotto() : QString(); }
UserStatus::UserStatusEnum PeopleInfoManager::getContactStatus(qint32 id) const { const ContactInfo *user = getContact(id); return (user != NULL) ? user->getStatus() : UserStatus::Offline; }
IrcContact *IrcAccount::getContact(const QString &nick, bool create) { return getContact(nick, QString(), create); }
int main( int argc, char *argv[] ) { try { _2Real::app::Engine testEngine; auto loadedBundle = testEngine.loadBundle( "TestBundle_BasicBlocksAndCustomTypes" ); // -------print the block metainfo--------- auto bundleinfo = loadedBundle.second; std::cout << "basic bundle info" << std::endl; std::cout << "description " << bundleinfo.getDescription() << std::endl; std::cout << "category " << bundleinfo.getCategory() << std::endl; std::cout << "author " << bundleinfo.getAuthor() << std::endl; std::cout << "contact " << bundleinfo.getContact() << std::endl; std::cout << "version " << bundleinfo.getVersion() << std::endl; std::cout << std::endl; // i know that these are custom types, so no need for casting around auto typeinfos = bundleinfo.getExportedTypes(); std::cout << "number of exported types : " << typeinfos.size() << std::endl; if ( !typeinfos.empty() ) std::cout << "--------------------------------" << std::endl; for ( auto it : typeinfos ) { printCustomTypeMetainfo( it ); std::cout << "--------------------------------" << std::endl; } std::cout << std::endl; auto blockinfos = bundleinfo.getExportedBlocks(); std::cout << "exported blocks " << blockinfos.size() << std::endl; for ( auto it : blockinfos ) { std::cout << "\t" << it.getName() << std::endl; std::cout << "\t" << it.getDescription() << std::endl; auto dependencies = it.getDependenciesByName(); std::cout << "\tdependencies\t"; for ( auto it : dependencies ) std::cout << it << " "; std::cout << std::endl; std::vector< _2Real::app::InletMetainfo > inletinfos = it.getInlets(); std::cout << "\tinlets " << inletinfos.size() << std::endl; for ( auto it : inletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; std::cout << "\t\tis multi " << std::boolalpha << it.isMulti() << std::endl; } std::vector< _2Real::app::OutletMetainfo > outletinfos = it.getOutlets(); std::cout << "\toutlets " << outletinfos.size() << std::endl; for ( auto it : outletinfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } std::vector< _2Real::app::ParameterMetainfo > paraminfos = it.getParameters(); std::cout << "\tparameters " << paraminfos.size() << std::endl; for ( auto it : paraminfos ) { std::cout << "\t\tname " << it.getName() << std::endl; std::cout << "\t\tdescription " << it.getDescription() << std::endl; std::cout << "\t\tdatatype " << it.getTypeMetainfo()->getName() << std::endl; std::cout << "\t\tinitial "; boost::apply_visitor< _2Real::PrintOutVisitor >( _2Real::PrintOutVisitor( std::cout ), it.getInitialValue() ); std::cout << std::endl; } } // -------create block instance--------- _2Real::app::TimerHandle timer = testEngine.createTimer( 5.0 ); _2Real::app::ThreadpoolHandle threadpool = testEngine.createThreadpool( _2Real::ThreadpoolPolicy::FIFO ); _2Real::app::BlockHandle counter = loadedBundle.first.createBlock( "counter", threadpool, std::vector< _2Real::app::BlockHandle >() ); _2Real::app::BlockIo counterio = counter.getBlockIo(); auto incInlet = std::dynamic_pointer_cast< _2Real::app::InletHandle >( counterio.mInlets[ 0 ] ); std::future< _2Real::BlockResult > setup = counter.setup(); handleFuture( setup ); std::future< _2Real::BlockResult > start = counter.startUpdating( timer ); handleFuture( start ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; else if ( line == "stop" ) { timer.stop(); } else if ( line == "start" ) { timer.start(); } } std::future< _2Real::BlockResult > stop = counter.stopUpdating(); handleFuture( stop ); std::future< _2Real::BlockResult > shutdown = counter.shutdown(); handleFuture( shutdown ); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } testEngine.clear(); while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } } catch ( _2Real::Exception &e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << " " << e.message() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } catch ( std::exception const& e ) { std::cout << "-------------exception caught in main------------" << std::endl; std::cout << e.what() << std::endl; std::cout << "-------------exception caught in main------------" << std::endl; } while( 1 ) { std::this_thread::yield(); std::string line; char lineEnd = '\n'; std::getline( std::cin, line, lineEnd ); if ( line == "q" ) break; } return 0; }