diff --git a/Makefile b/Makefile index ee4ff35..24b09db 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ strip: $(PRPL_LIBNAME) # TODO: Find a better place for server.pub install: $(PRPL_LIBNAME) install -D $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_LIBNAME) - install -D tg-server.pub /etc/telegram/server.pub + install -D tg-server.pub /etc/telegram-purple/server.pub install -D purple-plugin/telegram16.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/16/telegram.png install -D purple-plugin/telegram22.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/22/telegram.png install -D purple-plugin/telegram48.png $(DESTDIR)$(DATA_ROOT_DIR_PURPLE)/pixmaps/pidgin/protocols/48/telegram.png diff --git a/mtproto-client.c b/mtproto-client.c index 8e4a76c..1c7a635 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -117,8 +117,8 @@ int Response_len; * */ -#define TG_SERVER_PUBKEY_FILENAME "/etc/telegram/server.pub" -char *rsa_public_key_name; // = TG_SERVER_PUBKEY_FILENAME; +#define TG_SERVER_PUBKEY_FILENAME "/etc/telegram-purple/server.pub" +char *rsa_public_key_name = 0; RSA *pubKey; long long pk_fingerprint; diff --git a/mtproto-client.h b/mtproto-client.h index d90a748..fe6dcc1 100644 --- a/mtproto-client.h +++ b/mtproto-client.h @@ -114,6 +114,7 @@ Copyright Nikolay Durov, Andrey Lopatin 2012-2013 #define MAX_PROTO_MESSAGE_INTS 1048576 #define _FILE_OFFSET_BITS 64 +char *rsa_public_key_name; #pragma pack(push,4) struct encrypted_message { diff --git a/telegram-adium/TelegramPlugin.m b/telegram-adium/TelegramPlugin.m index 10d4943..acbf619 100644 --- a/telegram-adium/TelegramPlugin.m +++ b/telegram-adium/TelegramPlugin.m @@ -17,6 +17,7 @@ #import "TelegramPlugin.h" #import "TelegramService.h" #import "telegram-purple.h" +#import "mtproto-client.h" extern void purple_init_telegram_plugin(); @@ -24,6 +25,7 @@ extern void purple_init_telegram_plugin(); - (void) installPlugin { + rsa_public_key_name = [self getPkName]; purple_init_telegram_plugin(); [TelegramService registerService]; } @@ -55,4 +57,13 @@ extern void purple_init_telegram_plugin(); return @"Telegram"; } +-(char*)getPkName +{ + const char* utf8String = (char *)[[[NSBundle bundleForClass: [self class]] pathForResource: @"tg-server" ofType: @"pub"] UTF8String]; + size_t len = strlen(utf8String) + 1; + char *buf = talloc0(len); + memcpy(buf, utf8String, len); + return buf; +} + @end diff --git a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj index ede3757..069b0c7 100644 --- a/telegram-adium/telegram-adium.xcodeproj/project.pbxproj +++ b/telegram-adium/telegram-adium.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ C4B81AF119E087AF00E9177C /* AIUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B81AF019E087AF00E9177C /* AIUtilities.framework */; }; C4B81AF319E087BA00E9177C /* AdiumLibpurple.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B81AF219E087BA00E9177C /* AdiumLibpurple.framework */; }; C4B81AF519E087C500E9177C /* Adium.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4B81AF419E087C500E9177C /* Adium.framework */; }; + C4B81AF919E15E0D00E9177C /* tg-server.pub in Resources */ = {isa = PBXBuildFile; fileRef = C4B81AF619E0B67600E9177C /* tg-server.pub */; }; C4BF991C19BB8B4D0038D507 /* binlog.c in Sources */ = {isa = PBXBuildFile; fileRef = C4BF990419BB8B4D0038D507 /* binlog.c */; }; C4BF991D19BB8B4D0038D507 /* loop.c in Sources */ = {isa = PBXBuildFile; fileRef = C4BF990519BB8B4D0038D507 /* loop.c */; }; C4BF991E19BB8B4D0038D507 /* msglog.c in Sources */ = {isa = PBXBuildFile; fileRef = C4BF990619BB8B4D0038D507 /* msglog.c */; }; @@ -73,6 +74,7 @@ C4B81AF019E087AF00E9177C /* AIUtilities.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AIUtilities.framework; path = "../../../Library/Developer/Xcode/DerivedData/Adium-gdszlkyrczkyzvfhyhsigfyepffb/Build/Products/Debug/AIUtilities.framework"; sourceTree = ""; }; C4B81AF219E087BA00E9177C /* AdiumLibpurple.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdiumLibpurple.framework; path = "../../../Library/Developer/Xcode/DerivedData/Adium-gdszlkyrczkyzvfhyhsigfyepffb/Build/Products/Debug/AdiumLibpurple.framework"; sourceTree = ""; }; C4B81AF419E087C500E9177C /* Adium.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Adium.framework; path = "../../../Library/Developer/Xcode/DerivedData/Adium-gdszlkyrczkyzvfhyhsigfyepffb/Build/Products/Debug/Adium.framework"; sourceTree = ""; }; + C4B81AF619E0B67600E9177C /* tg-server.pub */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "tg-server.pub"; path = "../tg-server.pub"; sourceTree = ""; }; C4BF990419BB8B4D0038D507 /* binlog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = binlog.c; path = ../binlog.c; sourceTree = ""; }; C4BF990519BB8B4D0038D507 /* loop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = loop.c; path = ../loop.c; sourceTree = ""; }; C4BF990619BB8B4D0038D507 /* msglog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = msglog.c; path = ../msglog.c; sourceTree = ""; }; @@ -132,8 +134,8 @@ C4877C1719BB37EA006FA91F /* TelegramService.m */, C4877C1C19BB676B006FA91F /* AdiumTelegramAccount.h */, C4877C1D19BB676B006FA91F /* AdiumTelegramAccount.m */, - C4BF992619BB8B530038D507 /* telegram */, C4BF990319BB8B200038D507 /* telegram-purple */, + C4BF992619BB8B530038D507 /* telegram */, C410948B19BB2D7D0083BF3F /* telegram-adium */, C410948819BB2D7D0083BF3F /* Frameworks */, C410948719BB2D7D0083BF3F /* Products */, @@ -211,6 +213,7 @@ C4BF992619BB8B530038D507 /* telegram */ = { isa = PBXGroup; children = ( + C4B81AF619E0B67600E9177C /* tg-server.pub */, C4BF990419BB8B4D0038D507 /* binlog.c */, C4BF990519BB8B4D0038D507 /* loop.c */, C4BF990619BB8B4D0038D507 /* msglog.c */, @@ -290,6 +293,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C4B81AF919E15E0D00E9177C /* tg-server.pub in Resources */, C410949019BB2D7D0083BF3F /* InfoPlist.strings in Resources */, C4877C2619BB6D11006FA91F /* telegram16.png in Resources */, C4877C2519BB6D11006FA91F /* telegram.png in Resources */,