diff --git a/purple-plugin/telegram-purple.c b/purple-plugin/telegram-purple.c index b5d7b56..ab71b66 100644 --- a/purple-plugin/telegram-purple.c +++ b/purple-plugin/telegram-purple.c @@ -1270,11 +1270,11 @@ static PurplePluginInfo plugin_info = { PURPLE_PRIORITY_DEFAULT, PLUGIN_ID, "Telegram", - "0.1", - "Telegram protocol", - "Support for the protocol of the Telegram messenger.", - "Christopher Althaus , Markus Endres , Matthias Jentsch ", - "https://bitbucket.org/telegrampurple/telegram-purple", + TG_VERSION, + "Telegram", + TG_DESCRIPTION, + TG_AUTHOR, + "https://github.com/majn/telegram-purple", NULL, // on load NULL, // on unload NULL, // on destroy diff --git a/purple-plugin/telegram-purple.h b/purple-plugin/telegram-purple.h index 66ad820..25344e9 100644 --- a/purple-plugin/telegram-purple.h +++ b/purple-plugin/telegram-purple.h @@ -16,10 +16,14 @@ #ifndef __TG_PURPLE_H__ #define __TG_PURPLE_H__ -#define PLUGIN_ID "prpl-telegram" +#define PLUGIN_ID "prpl-telegram" #define TELEGRAM_AUTH_MODE_PHONE "phone" #define TELEGRAM_AUTH_MODE_SMS "sms" +#define TG_AUTHOR "Christopher Althaus , Markus Endres , Matthias Jentsch " +#define TG_DESCRIPTION "A protocol plugin that adds support for the Telegram messenger." +#define TG_VERSION "0.2.0" +#define TG_BUILD "2" #include #include "notify.h" diff --git a/telegram-adium/AdiumTelegramAccount.m b/telegram-adium/AdiumTelegramAccount.m index 608d03a..ec90117 100644 --- a/telegram-adium/AdiumTelegramAccount.m +++ b/telegram-adium/AdiumTelegramAccount.m @@ -15,14 +15,9 @@ return "prpl-telegram"; } -- (BOOL)connectivityBasedOnNetworkReachability -{ - return YES; -} - - (NSString *)host { - return @"173.240.5.1"; + return @"149.154.167.50"; } - (int)port @@ -30,32 +25,9 @@ return 443; } -/* -- (NSString *)encodedAttributedString:(NSAttributedString *)inAttributedString forListObject:(AIListObject *)inListObject -{ - NSString *temp = [AIHTMLDecoder encodeHTML:inAttributedString - headers:YES - fontTags:NO - includingColorTags:NO - closeFontTags:NO - styleTags:NO - closeStyleTagsOnFontChange:NO - encodeNonASCII:NO - encodeSpaces:NO - imagesPath:nil - attachmentsAsText:YES - onlyIncludeOutgoingImages:NO - simpleTagsOnly:YES - bodyBackground:NO - allowJavascriptURLs:NO]; - return temp; -} -*/ - - (BOOL)canSendOfflineMessageToContact:(AIListContact *)inContact { return YES; } - @end diff --git a/telegram-adium/TelegramPlugin.h b/telegram-adium/TelegramPlugin.h index bb0e985..7f5c848 100644 --- a/telegram-adium/TelegramPlugin.h +++ b/telegram-adium/TelegramPlugin.h @@ -6,11 +6,10 @@ // Copyright (c) 2014 Matthias Jentsch. All rights reserved. // -#import #import +#import -@interface TelegramPlugin : NSObject { - id service; +@interface TelegramPlugin : AIPlugin { + } - @end diff --git a/telegram-adium/TelegramPlugin.m b/telegram-adium/TelegramPlugin.m index 96bc7b9..9875ed5 100644 --- a/telegram-adium/TelegramPlugin.m +++ b/telegram-adium/TelegramPlugin.m @@ -6,21 +6,45 @@ // Copyright (c) 2014 Matthias Jentsch. All rights reserved. // -#import "telegram-purple.h" #import "TelegramPlugin.h" #import "TelegramService.h" +#import "telegram-purple.h" + +extern void purple_init_telegram_plugin(); @implementation TelegramPlugin - (void) installPlugin { - purple_init_telegram(); - service = [[TelegramService alloc] init]; + purple_init_telegram_plugin(); + [TelegramService registerService]; +} + +- (void) installLibpurplePlugin +{ +} + +- (void) loadLibpurplePlugin +{ } - (void) uninstallPlugin { - service = nil; +} + +- (NSString *)pluginAuthor +{ + return @TG_AUTHOR; +} + +-(NSString *)pluginVersion +{ + return @TG_VERSION; +} + +-(NSString *)pluginDescription +{ + return @"Telegram"; } @end diff --git a/telegram-adium/TelegramService.h b/telegram-adium/TelegramService.h index 48b8ed6..bcda57b 100644 --- a/telegram-adium/TelegramService.h +++ b/telegram-adium/TelegramService.h @@ -9,6 +9,8 @@ #import #import -@interface TelegramService : PurpleService +@interface TelegramService : PurpleService { + +} @end diff --git a/telegram-adium/TelegramService.m b/telegram-adium/TelegramService.m index 21ee175..61ddde4 100644 --- a/telegram-adium/TelegramService.m +++ b/telegram-adium/TelegramService.m @@ -9,17 +9,40 @@ #import "TelegramService.h" #import "AdiumTelegramAccount.h" +#import +#import + @implementation TelegramService - (Class)accountClass{ - return [AdiumOkCupidAccount class]; + return [AdiumTelegramAccount class]; } -/* -- (AIAccountViewController *)accountViewController { - return [OkCupidAccountViewController accountViewController]; +//Service Description +- (NSString *)serviceCodeUniqueID{ + return @"prpl-telegram"; +} + +- (NSString *)serviceID{ + return @"Telegram"; +} + +- (NSString *)serviceClass{ + return @"Telegram"; +} + +- (NSString *)shortDescription{ + return @"Telegram"; +} + +- (NSString *)longDescription{ + return @"Telegram"; +} + +- (NSString *)userNameLabel +{ + return @"Phone Number"; } - */ - (BOOL)supportsProxySettings{ return YES; @@ -32,67 +55,78 @@ - (BOOL)requiresPassword { - return NO; + return NO; +} + +- (BOOL)canCreateGroupChats +{ + return YES; } - (NSString *)UIDPlaceholder { - return @"Telegram"; -} - -//Service Description -- (NSString *)serviceCodeUniqueID{ - return @"prpl-telegram"; -} -- (NSString *)serviceID{ - return @"Telegram"; -} -- (NSString *)serviceClass{ - return @"Telegram"; -} -- (NSString *)shortDescription{ - return @"Telegram"; -} -- (NSString *)longDescription{ - return @"Support for the protocol of the Telegram messenger."; + return @"e.g. +49157123456"; } - (BOOL)isSocialNetworkingService { - return NO; + return YES; } +- (AIServiceImportance)serviceImportance{ + return AIServiceSecondary; +} - (NSCharacterSet *)allowedCharacters{ return [[NSCharacterSet illegalCharacterSet] invertedSet]; } -- (NSCharacterSet *)ignoredCharacters{ - return [NSCharacterSet characterSetWithCharactersInString:@""]; + +- (NSCharacterSet *)allowedCharactersForAccountName +{ + return ([NSCharacterSet characterSetWithCharactersInString: @"+1234567890"]); } + +- (NSUInteger)allowedLengthForAccountName +{ + return 16; +} + +- (NSCharacterSet *)ignoredCharacters{ + return [NSCharacterSet characterSetWithCharactersInString:@"/-"]; +} + - (BOOL)caseSensitive{ return NO; } -- (AIServiceImportance)serviceImportance{ - return AIServiceSecondary; -} + - (NSImage *)defaultServiceIconOfType:(AIServiceIconType)iconType { - NSImage *image; - NSString *imagename; - NSSize imagesize; - - if (iconType == AIServiceIconLarge) - { - imagename = @"telegram"; - imagesize = NSMakeSize(48,48); - } else { - imagename = @"telegram16"; - imagesize = NSMakeSize(16,16); - } - - image = [NSImage imageNamed:(imagename)]; // TODO: forClass:[self class] loadLazily:YES] - [image setSize:imagesize]; - return image; + if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) { + return [NSImage imageNamed:@"telegram16" forClass:[self class] loadLazily:YES]; + } else { + return [NSImage imageNamed:@"telegram" forClass:[self class] loadLazily:YES]; + } +} + +- (NSString *)pathForDefaultServiceIconOfType:(AIServiceIconType)iconType +{ + if ((iconType == AIServiceIconSmall) || (iconType == AIServiceIconList)) { + return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"telegram16"]; + } + return [[NSBundle bundleForClass:[self class]] pathForImageResource:@"telegram"]; +} + +- (void)registerStatuses { +#define ADDSTATUS(name, type) \ +[adium.statusController registerStatus:name \ +withDescription:[adium.statusController localizedDescriptionForCoreStatusName:name] \ +ofType:type forService:self] + + [adium.statusController registerStatus:STATUS_NAME_AVAILABLE withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AVAILABLE] ofType:AIAvailableStatusType forService:self]; + + ADDSTATUS(STATUS_NAME_AVAILABLE, AIAvailableStatusType); + ADDSTATUS(STATUS_NAME_NOT_AVAILABLE, AIAvailableStatusType); + ADDSTATUS(STATUS_NAME_OFFLINE, AIOfflineStatusType); } @end