CarLinkPlayer.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #ifndef CARLINKPLAYER_H
  2. #define CARLINKPLAYER_H
  3. #ifdef __cplusplus
  4. #ifdef USE_DBUS
  5. #include "ArkDbus.h"
  6. #include "InterfaceCallback.h"
  7. #endif
  8. #include "IUserLinkPlayer.h"
  9. #include "LinkAssist.h"
  10. #include "WiFiManager.h"
  11. #include <vector>
  12. #include <mutex>
  13. using namespace std;
  14. #define ArkMicroLinkService "com.arkmicro.carlink"
  15. #define ArkMicroLinkPath "/com/arkmicro/carlink"
  16. #define ArkMicroLinkInterface "Local.DbusServer.CarLink"
  17. class CarLinkPlayer;
  18. class CarBack;
  19. #ifdef USE_DBUS
  20. class InterfaceCallbackImpl : public InterfaceCallback
  21. {
  22. public:
  23. InterfaceCallbackImpl(CarLinkPlayer* handle) : mHandle(handle) {}
  24. protected:
  25. void start(int type, int mode, int state);
  26. void touch(int x, int y, int press);
  27. void multi_touch(int x1, int y1, int press1, int x2, int y2, int press2);
  28. void key(int key);
  29. void wheel(int wheel, bool foucs);
  30. void night_mode(bool night);
  31. void right_hand_dirver(bool right);
  32. void disable_car_audio(bool disable);
  33. void page(int page);
  34. void phone_ip(string ipstring);
  35. void phone_bt(string btstring);
  36. void car_bluetooch(string name, string address, string pin);
  37. void wifi(string ssid, string passphrase, string channel_id);
  38. void license(string lisence);
  39. void input_text(string text);
  40. void input_selection(int start, int stop);
  41. void input_action(int actionId, int keyCode);
  42. void screen_size(int width, int height);
  43. void bluetooth_cmd(string cmd);
  44. void broadcast(bool enable);
  45. void delay_record(int millisecond);
  46. void wifi_state_changed(int action, int state, string phoneIp, string carIp);
  47. private:
  48. CarLinkPlayer* mHandle;
  49. };
  50. #endif
  51. class CarLinkPlayer
  52. {
  53. public:
  54. CarLinkPlayer();
  55. virtual ~CarLinkPlayer();
  56. void initialize();
  57. void registerAppStatus(void(*pAppStatusCallback)(int,void*));
  58. void registerUsbState(void(*pUsbStateCallback)(int,int));
  59. #ifdef dbus_send_signal
  60. void onLinkStatus(const int type, const int mode, const int status); //send carlink's status to UI
  61. void onDateTime(const int type, const long long time); //send carlink's timer to UI
  62. void onTelephone(const int type, const string name, const string number); //send carlink's information to buletooth
  63. void onPhoneType(const int type, int inserted); //send carlink's type to UI
  64. void onCarCmd(const int type, const int carcmd); //send carlink's voices controls to UI change state (eclink)
  65. void onLicenseStatus(const int type, int activate, int code, string msg, string ver); //send carlink's license to UI (eclink)
  66. void onInputStart(const int type, const int inputType, const int imeOptions, const string rawText, const int minLines, const int maxLines, const int maxLength); //send carlink's keyboard state to UI(eclink)
  67. void onInputSelection(const int type, const int start, const int stop); //send carlink's keyboard select area (elink)
  68. void onVrTextinfoChange(const int type, const int vrtype, const int sequence, const string plainText, const string htmlText); //send link's voices change text to UI (eclink)
  69. void onCarLinkVersion(const int type, const string ver); //send carlink's version to UI
  70. void onLinkDuckAudio(const int type, double durationSecs, double volume); //send carlink's audio duck volume
  71. void onLinkUnduckAudio(const int type, double durationSecs); //send carlink's audio unduck volume
  72. void onPinCode(const int type, const string pincode); //send carlink's pincode(hicar)
  73. void onBlueToothCmd(const int type, const string cmd); //send carlink's bluetooth of "AT" cmd
  74. void onCarLinkInitDone(const int type); //send carlink's initialize finished
  75. void onPhoneBlueToothInfo(const int type, const string phoneBTAddr, const int pairMethod); //send carlink's phone bluetooth address
  76. void onLinkMsgInfo(const int type, const string msgInfo, const int msgLen); //send carlink's message information
  77. #endif
  78. public:
  79. #ifdef USE_DBUS
  80. void requestLink(LinkType linkType, LinkMode linkMode, DbusReceive status); //UI request carlink's connect
  81. void requestTouch(int x, int y, TouchCode pressed); //UI request carlink's touch coordinate
  82. void requestMultiTouch(int x1, int y1, TouchCode pressed1,int x2, int y2, TouchCode pressed2); //UI request carlink's multi touch coordinate
  83. void requestKey(KeyCode key); //UI request carlink's key value
  84. void requestWheel(WheelCode wheelCode, bool bFoucs); //UI request carlink's wheel value
  85. void requestPage(AppPage appPage); //UI request carlink's open page
  86. void requestNightMode(bool night); //UI request carlink's night mode
  87. void requestRightHandDriver(bool right); //UI request carlink's driver mode
  88. void requestDisableCarAudio(bool disable); //UI request carlink's disable car audio
  89. void requestPhoneIPAddress(string str); //UI request carlink's connected phone's ip address
  90. void requestPhoneBTAddress(string str); //UI request carlink's connected phone's bt address
  91. void requestCarBluetooth(string name, string address, string pin); //UI request carlink's bluetooth address
  92. void requestWifi(string ssid, string passphrase, string channel_id); //UI request carlink's wifi information
  93. void requestLicense(string license); //UI request carlink's license(eclink)
  94. void requestInputText(string text); //UI request carlink's keyboard input text(eclink)
  95. void requestInputSelection(int start, int stop); //UI request carlink's keyboard input selection(eclink)
  96. void requestInputAction(int actionId, int keyCode); //UI request carlink's keyboard input action(eclink)
  97. void requestScreenSize(int width, int height); //UI request carlink's screen size
  98. void requestBluetoothCmd(string cmd); //UI requset carlink's bt cmd
  99. void requestBroadcast(bool enable); //UI requset carlink's wireless pincode
  100. void requestDelayRecord(int millisecond); //UI requset carlink's delay record
  101. void requestWifiStateChanged(WifiStateAction action, WifiState state, string phoneIp, string carIp);//UI request carlink's wireless wifi state(eclink)
  102. #endif
  103. public:
  104. void Start(LinkType linkType, LinkMode linkMode);
  105. void Stop();
  106. IUserLinkPlayer* UIPlayer() const {return mPlayer;}
  107. protected:
  108. void app_status(AppStatusMessage appStatusMessage, void *reserved);
  109. void usb_state(ConnectedStatus status, PhoneType type);
  110. //void wifi_state(WiFiConnectStatus state);
  111. void wifi_state(PT_PhoneType type, WiFiConnectStatus status);
  112. void carlink_connect_state(ConnectedStatus status, PhoneType type);
  113. void carlink_phone(CallType type, char* name, char* number);
  114. void CarbackState(int state);
  115. private:
  116. IUserLinkPlayer *mPlayer;
  117. LinkAssist *mpLinkAssist;
  118. #ifdef USE_DBUS
  119. InterfaceCallback *mpCallbacks;
  120. #endif
  121. bool mChangeMode;
  122. ConnectedStatus mConnectStatus;
  123. PhoneType mPhoneType;
  124. LinkType mLinkType;
  125. LinkMode mLinkMode;
  126. bool mIsRunningBackGround;
  127. string mstrBtAddress;
  128. string mstrIpAddress;
  129. //CarBack *mpCarback;
  130. //bool mCarback;
  131. WifiInfo mWifiInfo;
  132. BlueToothInfo mBlueToothInfo;
  133. string mLicense;
  134. int mNightMode;
  135. int mRightHandDriver;
  136. int mDisableCarAudio;
  137. int mScreenWidth;
  138. int mScreenHeight;
  139. int mMillisecond;
  140. vector<string> mVecBlueToothCmd;
  141. bool mStartCarLink;
  142. std::mutex mMutex;
  143. void (*mAppStatus)(int, void*);
  144. void (*mUsbState)(int, int);
  145. };
  146. #endif
  147. #endif // CARLINKPLAYER_H