Changeset 13980
- Timestamp:
- 05/30/12 12:45:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/skypeclient.cc
r13966 r13980 32 32 33 33 bool fAllowRaw; 34 35 uint64_t fLastReadMessage; 34 36 35 37 string Contact(const string &id) const … … 424 426 if (vec[0]=="CHATMESSAGE") 425 427 { 426 if (vec[2]=="STATUS" && vec[3]=="RECEIVED") 427 { 428 if (vec[2]=="STATUS" && (vec[3]=="RECEIVED"|| vec[3]=="READ")) 429 { 430 const uint64_t last = stoll(vec[1]); 431 432 // Check if message has already been processed: Sometimes 433 // some messages are received twice as READ/READ 434 if (last<=fLastReadMessage) 435 return; 436 fLastReadMessage = last; 437 428 438 string rc; 429 439 … … 436 446 const size_t p = rc.find(" BODY "); 437 447 if (p==string::npos) 448 { 449 cout<< "BODY TAG NOT FOUND|" << rc << "|" << endl; 438 450 return; 439 440 rc = rc.substr(rc.find(" BODY ")+6); 451 } 452 453 rc = Tools::Trim(rc.substr(rc.find(" BODY ")+6)); 441 454 442 455 if (rc=="start") … … 467 480 } 468 481 469 if (rc==" list")482 if (rc=="status") 470 483 { 471 ostringstream out;472 out << "*\n\nCurrently subscribed:\n";473 474 int cnt = 0;475 484 for (auto it=fContacts.begin(); it!=fContacts.end(); it++) 476 485 { 477 const string user = Contact(*it); 478 if (user.empty()) 479 continue; 480 481 out << " * " << user << '\n'; 482 cnt ++; 486 if (*it==vec[1]) 487 { 488 SendSkypeMessage(id, "You are subscribed."); 489 return; 490 } 483 491 } 484 485 if (cnt==0) 486 out << " <no subscriptions>"; 487 else 488 out << cnt << " user(s) subscribed."; 489 490 SendSkypeMessage(id, out.str()); 492 SendSkypeMessage(id, "You are not subscribed."); 491 493 return; 492 494 } 493 495 494 SendSkypeMessage(id, " *\n\nSyntax Error:\nPlease use either 'start' or 'stop'");496 SendSkypeMessage(id, "SYNTAX ERROR\n\nAvailable commands:\nPlease use either 'start', 'stop' or 'status'"); 495 497 496 498 } … … 502 504 if (vec[2]=="ACTIVITY_TIMESTAMP") 503 505 { 506 //SendDBusMessage("CHAT CREATE "+Contact(vec[1])); 504 507 //Info(vec[2]); 508 // ALTER CHAT DISBAND 505 509 } 506 510 if (vec[2]=="MYROLE") … … 541 545 } 542 546 547 int HandleDisconnect() 548 { 549 return kStateDisconnected; 550 } 551 543 552 int HandleConnect() 544 553 { … … 619 628 public: 620 629 SkypeClient(ostream &lout) : StateMachineDim(lout, "SKYPE"), 621 fLastConnect(Time()-boost::posix_time::minutes(5)), fLoop(0) 630 fLastConnect(Time()-boost::posix_time::minutes(5)), fLoop(0), 631 fLastReadMessage(0) 622 632 { 623 633 AddStateName(kStateDisconnected, "Disonnected", ""); … … 638 648 AddEvent("CONNECT", kStateDisconnected) 639 649 (bind(&SkypeClient::HandleConnect, this)) 650 (""); 651 652 AddEvent("DISCONNECT", kStateConnected) 653 (bind(&SkypeClient::HandleDisconnect, this)) 640 654 (""); 641 655
Note:
See TracChangeset
for help on using the changeset viewer.