Chatsync  bbffde5c0c672a526bdc83637acf66dc20a80fbf
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
toxchannel.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "channel.hpp"
3 #include <tox/tox.h>
4 
5 namespace toxChannel {
6 
7  constexpr auto defaultBootstrapAddress = "23.226.230.47";
8  constexpr auto defaultBootstrapPort = "33445";
9  constexpr auto defaultBootstrapKey = "A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074";
10  // constexpr auto defaultBootstrapKey = "F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67";
11 
12  constexpr auto cmd_invite = "invite";
13  constexpr auto cmd_conference = "conference";
14 
15 
16  constexpr auto defaultBotName = "chatsyncbot";
17  constexpr auto defaultStatusMessage = "Online";
18  constexpr auto defaultBotStatus = TOX_USER_STATUS_NONE;
23  Tox * const _tox;
24  int toxStart();
25  std::future<void> activate() override;
27 
28  static void friendRequestCallback(Tox* tox, const uint8_t* public_key, const uint8_t* data, size_t length, void* userdata);
29  static void messageCallback(Tox* tox, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t* message, size_t length, void* userdata);
30 #ifdef CTOXCORE
31  static void groupMessageCallback(Tox* tox, uint32_t conference_number, uint32_t peer_number, TOX_MESSAGE_TYPE type, const uint8_t* message, size_t length, void* user_data);
32 #else
33  template <typename MsgType>
34  static void groupMessageCallback(Tox* tox, int32_t groupnumber, int32_t peernumber, const uint8_t* message, uint16_t length, void* userdata);
35 #endif
37 
38  const messaging::message_ptr parse(const char* line) const override;
39  void pollThread() override;
40  public:
41  explicit ToxChannel(Hub::Hub* hub, const std::string& config);
42  ~ToxChannel();
43 
44  std::string type() const override { return "tox"; };
45 
46  protected:
47  void incoming(const messaging::message_ptr&& msg) override;
48  };
50 }
std::future< void > activate() override
Definition: toxchannel.cpp:115
const messaging::message_ptr parse(const char *line) const override
Definition: toxchannel.cpp:294
Tox *const _tox
Definition: toxchannel.hpp:23
bool wasConnected
Definition: toxchannel.hpp:26
std::string type() const override
Definition: toxchannel.hpp:44
Definition: config.cpp:10
static void friendRequestCallback(Tox *tox, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
Definition: toxchannel.cpp:195
static void groupMessageCallback(Tox *tox, int32_t groupnumber, int32_t peernumber, const uint8_t *message, uint16_t length, void *userdata)
Definition: toxchannel.cpp:273
ToxChannel(Hub::Hub *hub, const std::string &config)
Definition: toxchannel.cpp:109
int toxStart()
Definition: toxchannel.cpp:306
Definition: toxchannel.hpp:22
std::shared_ptr< const Message > message_ptr
Definition: message.hpp:36
constexpr auto cmd_conference
Definition: toxchannel.hpp:13
Definition: channel.hpp:225
static void messageCallback(Tox *tox, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *userdata)
Definition: toxchannel.cpp:202
~ToxChannel()
Definition: toxchannel.cpp:171
constexpr auto defaultBootstrapKey
Definition: toxchannel.hpp:9
constexpr auto cmd_invite
Definition: toxchannel.hpp:12
constexpr auto defaultBootstrapPort
Definition: toxchannel.hpp:8
Definition: toxchannel.cpp:12
Definition: channel.hpp:63
constexpr auto defaultBotName
Definition: toxchannel.hpp:16
Definition: hub.hpp:24
constexpr auto defaultBotStatus
Definition: toxchannel.hpp:18
void incoming(const messaging::message_ptr &&msg) override
Definition: toxchannel.cpp:126
constexpr auto defaultStatusMessage
Definition: toxchannel.hpp:17
void pollThread() override
Definition: toxchannel.cpp:158
constexpr auto defaultBootstrapAddress
Definition: toxchannel.hpp:7
static const channeling::ChannelCreatorImpl< ToxChannel > creator
Definition: toxchannel.hpp:36