carlink.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef LINK_H
  2. #define LINK_H
  3. #include <QObject>
  4. #include <QScopedPointer>
  5. #include <QCoreApplication>
  6. #include "LinkBase.h"
  7. #include "carlinkproxy.h"
  8. struct TouchEvent {
  9. enum TouchPointState {
  10. TouchPointPressed = 0x01,
  11. TouchPointMoved = 0x02,
  12. TouchPointStationary = 0x04,
  13. TouchPointReleased = 0x08,
  14. };
  15. TouchEvent(){}
  16. explicit TouchEvent(TouchEvent::TouchPointState state, int x, int y)
  17. : state(state)
  18. , y(y)
  19. , x(x) {}
  20. ~TouchEvent() {}
  21. TouchEvent::TouchPointState state;
  22. int y;
  23. int x;
  24. };
  25. class LinkPrivate;
  26. class Link : public QObject
  27. {
  28. Q_OBJECT
  29. Q_DISABLE_COPY(Link)
  30. #ifdef g_Link
  31. #undef g_Link
  32. #endif
  33. #define g_Link (Link::instance())
  34. public:
  35. inline static Link* instance() {
  36. static Link* link(new Link(qApp));
  37. return link;
  38. }
  39. void requestLink(const int type, const int mode, const int status);
  40. void requestTouch(int x, int y, int pressed);
  41. void requestWifi(string ssid, string passphrase, string channel_id);
  42. void requestCarBluetooth(string name, string address, string pin);
  43. void requestPhoneIPAddress(string str); //UI request carlink's connected phone's ip address
  44. void requestPhoneBTAddress(string str);
  45. void setLinkType(int linkType);
  46. int getLinkType();
  47. void setLinkConnectStatus(int status);
  48. int getLinkConnectStatus();
  49. void setDbusConnectStatus(int status);
  50. int getDbusConnectStatus();
  51. void setLinkMode(int mode);
  52. int getLinkMode();
  53. void requestBluetoothCmd(string cmd); //UI requset carlink's bt cmd
  54. void requestBroadcast(bool enable); //UI requset carlink's wireless pincode
  55. bool getHicarInitStatus();
  56. void setHicarInitStatus(bool init);
  57. void requestKey(KeyCode key); //UI request carlink's key value
  58. void requestNightMode(bool night);
  59. void setHicaiInitDone(bool status);
  60. bool getHicarInitDoneStatu();
  61. signals:
  62. void onLinkStatus(const int type, const int mode, const int status);
  63. void onCarLinkVersion(const int type, const QString ver);
  64. void onPhoneType(const int type, const int inserted);
  65. void onDateTime(const int type, const long long time);
  66. void onPinCode(const int type, const QString pincode); //send carlink's pincode(hicar)
  67. void onBlueToothCmd(const int type, const QString cmd); //send carlink's bluetooth of "AT" cmd
  68. void onCarLinkInitDone(const int type);
  69. void onLinkDuckAudio(const int type, double durationSecs, double volume);//send carlink's audio duck volume
  70. void onLinkUnduckAudio(const int type, double durationSecs);//send carlink's audio unduck volume
  71. void onTelephone(const int type, const QString name, const QString number);
  72. private:
  73. explicit Link(QObject *parent = NULL);
  74. ~Link();
  75. Local::DbusServer::CarLink* m_CarLinkProxy;
  76. LinkPrivate* const d_ptr;
  77. Q_DECLARE_PRIVATE(Link)
  78. };
  79. #endif // LINK_H