messagewrapper.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef MESSAGEWRAPPER_H
  2. #define MESSAGEWRAPPER_H
  3. #include "QXmppMessage.h"
  4. //#include "QXmppPacket.h"
  5. #include <QMap>
  6. #include <QDateTime>
  7. #include <QVariant>
  8. #include <QtDeclarative>
  9. #include "msgitemmodel.h"
  10. #include "msglistmodel.h"
  11. #include "mysmiles.h"
  12. class MyXmppClient;
  13. class MeegimMessage
  14. {
  15. public:
  16. MeegimMessage() { dlr = false; msg = ""; id = ""; myMsg = false; resource = ""; }
  17. bool dlr;
  18. bool myMsg;
  19. QString id;
  20. QString resource;
  21. QString msg;
  22. QDateTime date;
  23. void toString() {
  24. qDebug()<<"MSG: ["<<date.toString("hh:mm:ss")<<"] id:["<<id<<"] isMy:["<<myMsg<<"] dlr:["<<dlr<<"] txt:["<<msg<<"]";
  25. }
  26. };
  27. class MessageWrapper : public QObject
  28. {
  29. Q_OBJECT
  30. //QDeclarativeView *qmlObj;
  31. MsgListModel *mlm;
  32. QXmppMessage *xmppMessage;
  33. //QVariantMap qmlBufOpenChats;
  34. /* "jid" => list of MeegimMessage */
  35. QMap<QString, QList<MeegimMessage>* > listOfChats;
  36. QString openChatJid;
  37. QString m_myBareJid;
  38. MySmiles *smiles;
  39. QString parseMsgOnLink( const QString &inString ) const;
  40. QMap< QString, QString > bufAttentions;
  41. public:
  42. explicit MessageWrapper(QObject *parent = 0);
  43. void initChat( QString jid );
  44. void clearChat( QString bareJid );
  45. void hideChat() { openChatJid = ""; }
  46. void setMyJid( const QString &myBareJid ) { m_myBareJid = myBareJid; }
  47. void setChatBareJid( const QString &chatBareJid ) { openChatJid = chatBareJid; }
  48. void removeListOfChat( QString &bareJid );
  49. MsgListModel* getMessages() const { return mlm; }
  50. void textMessage(const QXmppMessage &xmppMsg);
  51. void attention( const QString &bareJid, const bool isMsgMine );
  52. signals:
  53. void openChat(QString jid);
  54. //void sendMyMsg( const QXmppMessage &xmppMsg );
  55. public slots:
  56. void messageReceived( const QXmppMessage &xmppMsg ); //don't use - depricated
  57. void messageDelivered( const QString &jid, const QString &id );
  58. };
  59. #endif // MESSAGEWRAPPER_H