diff options
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/stdafx.h | 19 | ||||
-rw-r--r-- | protocols/Telegram/src/t_callback.cpp | 27 | ||||
-rw-r--r-- | protocols/Telegram/src/t_callback.h | 1 | ||||
-rw-r--r-- | protocols/Telegram/src/t_messages.cpp | 6 | ||||
-rw-r--r-- | protocols/Telegram/src/t_messages.h | 0 | ||||
-rw-r--r-- | protocols/Telegram/src/t_network.cpp | 6 | ||||
-rw-r--r-- | protocols/Telegram/src/t_network.h | 0 | ||||
-rw-r--r-- | protocols/Telegram/src/t_proto.cpp | 15 | ||||
-rw-r--r-- | protocols/Telegram/src/t_proto.h | 13 |
9 files changed, 75 insertions, 12 deletions
diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h index b6fce8c0ed..6c0c2016cb 100644 --- a/protocols/Telegram/src/stdafx.h +++ b/protocols/Telegram/src/stdafx.h @@ -1,9 +1,6 @@ #ifndef _STDAFX_H_
#define _STDAFX_H_
-//#pragma comment(lib, "$(SolutionDir)$(Configuration)\Obj\tgl\tgl.lib")
-
-#define TELEGRAM_APP_ID 17193
#include "..\..\..\miranda-private-keys\Telegram\api.h"
#include <windows.h>
@@ -41,12 +38,24 @@ #include <m_assocmgr.h>
#include <m_file.h>
-extern "C" {
-#include "tgl\tgl.h"
+extern "C"
+{
+ #include "tgl\tgl.h"
+ #include "tgl\tgl-net.h"
+ #include "tgl\tgl-timers.h"
}
+struct MirTLS : public tgl_state, public MZeroedObject
+{
+ struct CTelegramProto *m_proto;
+};
+
#include "version.h"
#include "t_proto.h"
+#include "t_network.h"
+#include "t_callback.h"
+
+extern char g_szMirVer[];
#define MODULE "Telegram"
diff --git a/protocols/Telegram/src/t_callback.cpp b/protocols/Telegram/src/t_callback.cpp new file mode 100644 index 0000000000..97d7eb0d1a --- /dev/null +++ b/protocols/Telegram/src/t_callback.cpp @@ -0,0 +1,27 @@ +#include "stdafx.h"
+
+static void update_message_handler(tgl_state *TLS, tgl_message *msg)
+{
+ ((MirTLS*)TLS)->m_proto->OnMessage(msg);
+}
+
+static void logprintf(const char *fmt, ...)
+{
+ CMStringA str("[Telegram]: ");
+ va_list args;
+ va_start(fmt, args);
+ str.AppendFormatV(fmt, args);
+ va_end(args);
+ CallService(MS_NETLIB_LOG, 0, (LPARAM)str.GetString());
+}
+
+void CTelegramProto::InitCallbacks()
+{
+ tgl_update_callback cb = { 0 };
+ cb.new_msg = update_message_handler;
+ cb.msg_receive = update_message_handler;
+ cb.logprintf = logprintf;
+
+ tgl_set_callback(TLS, &cb);
+
+}
\ No newline at end of file diff --git a/protocols/Telegram/src/t_callback.h b/protocols/Telegram/src/t_callback.h new file mode 100644 index 0000000000..d3f5a12faa --- /dev/null +++ b/protocols/Telegram/src/t_callback.h @@ -0,0 +1 @@ +
diff --git a/protocols/Telegram/src/t_messages.cpp b/protocols/Telegram/src/t_messages.cpp new file mode 100644 index 0000000000..0ba8cfa0bb --- /dev/null +++ b/protocols/Telegram/src/t_messages.cpp @@ -0,0 +1,6 @@ +#include "stdafx.h"
+
+void CTelegramProto::OnMessage(tgl_message*)
+{
+
+}
\ No newline at end of file diff --git a/protocols/Telegram/src/t_messages.h b/protocols/Telegram/src/t_messages.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/protocols/Telegram/src/t_messages.h diff --git a/protocols/Telegram/src/t_network.cpp b/protocols/Telegram/src/t_network.cpp new file mode 100644 index 0000000000..3bc7b1089d --- /dev/null +++ b/protocols/Telegram/src/t_network.cpp @@ -0,0 +1,6 @@ +#include "stdafx.h"
+
+void CTelegramProto::InitNetwork()
+{
+ tgl_set_net_methods(TLS, &tgl_conn_methods);
+}
\ No newline at end of file diff --git a/protocols/Telegram/src/t_network.h b/protocols/Telegram/src/t_network.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/protocols/Telegram/src/t_network.h diff --git a/protocols/Telegram/src/t_proto.cpp b/protocols/Telegram/src/t_proto.cpp index d87895a0cd..fd495a7f5f 100644 --- a/protocols/Telegram/src/t_proto.cpp +++ b/protocols/Telegram/src/t_proto.cpp @@ -19,15 +19,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. CTelegramProto::CTelegramProto(const char* protoName, const TCHAR* userName) : PROTO<CTelegramProto>(protoName, userName)
{
- tgl_register_app_id(&tgl, TELEGRAM_APP_ID, TELEGRAM_API_HASH);
- char version[64];
- mir_snprintf(version, "Miranda Telegram %d.%d.%d.%d", __MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM);
- tgl_set_app_version(&tgl, version);
- tgl_init(&tgl);
+ TLS = new MirTLS;
- tgl_update_callback tgucb = {};
+ InitNetwork();
+ tgl_set_timer_methods(TLS, &tgl_libevent_timers);
+ tgl_set_rsa_key(TLS, TELEGRAM_PUBLIC_KEY);
+ tgl_register_app_id(TLS, TELEGRAM_API_ID, TELEGRAM_API_HASH);
+ tgl_set_app_version(TLS, g_szMirVer);
+
+
+ tgl_init(TLS);
}
CTelegramProto::~CTelegramProto()
diff --git a/protocols/Telegram/src/t_proto.h b/protocols/Telegram/src/t_proto.h index 4b486cafbe..927718340e 100644 --- a/protocols/Telegram/src/t_proto.h +++ b/protocols/Telegram/src/t_proto.h @@ -63,6 +63,9 @@ public: void InitPopups();
void UninitPopups();
+ void InitNetwork();
+ void InitCallbacks();
+
// languages
static void InitLanguages();
@@ -77,11 +80,19 @@ public: static INT_PTR EventGetIcon(WPARAM wParam, LPARAM lParam);
static INT_PTR GetEventText(WPARAM, LPARAM lParam);
+
+
+ void OnMessage(tgl_message*);
+
+
+
+
private:
- tgl_state tgl;
+ MirTLS *TLS;
static mir_cs accountsLock;
+
//---Accounts
static LIST<CTelegramProto> CTelegramProto::Accounts;
static int CompareAccounts(const CTelegramProto *p1, const CTelegramProto *p2);
|