qmlxmppclient.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "qmlxmppclient.h"
  2. #include <QDebug>
  3. QMLXmppClient* QMLXmppClient::instance = 0;
  4. QMLXmppClient::QMLXmppClient(QObject *parent) : QObject(parent)
  5. {
  6. qDebug() << "QMLXmppClient:[" << this << "]";
  7. QMLXmppClient::instance = this;
  8. m_stateConnect = MYXMPP_DISCONNECTED;
  9. jidLastMessage = "";
  10. flTyping = false;
  11. m_myjid = "";
  12. }
  13. int QMLXmppClient::MYXMPP_CONNECTING = 0;
  14. int QMLXmppClient::MYXMPP_CONNECTED = 1;
  15. int QMLXmppClient::MYXMPP_DISCONNECTED = 2;
  16. void QMLXmppClient::setStateConnect( const int st )
  17. {
  18. if( st == QMLXmppClient::MYXMPP_CONNECTING ) {
  19. m_stateConnect = QMLXmppClient::MYXMPP_CONNECTING;
  20. emit connectingChanged();
  21. } else if( st == QMLXmppClient::MYXMPP_CONNECTED ) {
  22. m_stateConnect = QMLXmppClient::MYXMPP_CONNECTED;
  23. emit connectingChanged();
  24. } else if( st == QMLXmppClient::MYXMPP_DISCONNECTED ) {
  25. m_stateConnect = QMLXmppClient::MYXMPP_DISCONNECTED;
  26. emit connectingChanged();
  27. }
  28. }
  29. void QMLXmppClient::setStatusText( const QString &__statusText, const bool flNotify )
  30. {
  31. m_statusText = __statusText;
  32. if( flNotify ) {
  33. emit statusTextChanged();
  34. }
  35. }
  36. void QMLXmppClient::setStatus( QXmppPresence::Status::Type __status, const bool flNotify )
  37. {
  38. if( __status == QXmppPresence::Status::Online ) {
  39. m_status = Online;
  40. } else if( __status == QXmppPresence::Status::Chat ) {
  41. m_status = Chat;
  42. } else if ( __status == QXmppPresence::Status::Away ) {
  43. m_status = Away;
  44. } else if ( __status == QXmppPresence::Status::XA ) {
  45. m_status = XA;
  46. } else if( __status == QXmppPresence::Status::DND ) {
  47. m_status = DND;
  48. } else if( __status == QXmppPresence::Status::Offline ) {
  49. m_status = Offline;
  50. }
  51. if( flNotify ) {
  52. emit statusChanged();
  53. }
  54. }