Add custom preferences views for the Adium plugin

This commit is contained in:
mjentsch 2015-03-14 18:00:37 +01:00
parent 5a6b08f60f
commit 4382e1d779
10 changed files with 382 additions and 24 deletions

View file

@ -22,6 +22,8 @@
#import <Adium/AIListContact.h>
#import "tgp-ft.h"
#include "telegram-purple.h"
@implementation AdiumTelegramAccount
- (const char*)protocolPlugin
@ -44,6 +46,37 @@
return 443;
}
- (void)configurePurpleAccount
{
[super configurePurpleAccount];
purple_account_set_string (account, TGP_KEY_ACCEPT_SECRET_CHATS,
[[self preferenceForKey:@"Telegram:"TGP_KEY_ACCEPT_SECRET_CHATS
group:GROUP_ACCOUNT_STATUS]
UTF8String]);
purple_account_set_bool (account, TGP_KEY_DISPLAY_READ_NOTIFICATIONS,
[[self preferenceForKey:@"Telegram:"TGP_KEY_DISPLAY_READ_NOTIFICATIONS
group:GROUP_ACCOUNT_STATUS]
boolValue]);
purple_account_set_bool (account, TGP_KEY_HISTORY_SYNC_ALL,
[[self preferenceForKey:@"Telegram:"TGP_KEY_HISTORY_SYNC_ALL
group:GROUP_ACCOUNT_STATUS]
boolValue]);
purple_account_set_int (account, TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD,
[[self preferenceForKey:@"Telegram:"TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD
group:GROUP_ACCOUNT_STATUS]
intValue]);
purple_account_set_int (account, TGP_KEY_INACTIVE_DAYS_OFFLINE,
[[self preferenceForKey:@"Telegram:"TGP_KEY_INACTIVE_DAYS_OFFLINE
group:GROUP_ACCOUNT_STATUS]
intValue]);
}
- (BOOL)canSendOfflineMessageToContact:(AIListContact *)inContact
{
return YES;

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Telegram:accept-secret-chats</key>
<string>ask</string>
<key>Telegram:inactive-days-offline</key>
<string>7</string>
<key>Telegram:display-read-notifications</key>
<false/>
<key>Telegram:history-retrieve-days</key>
<string>14</string>
<key>Telegram:history-sync-all</key>
<false/>
</dict>
</plist>

View file

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="TelegramAccountViewController">
<connections>
<outlet property="checkbox_displayReadNotifications" destination="Tat-1e-jqI" id="1m9-1n-bKm"/>
<outlet property="checkbox_historySyncAll" destination="Qob-Rq-UJj" id="1dM-ig-DQa"/>
<outlet property="radio_Encryption" destination="RGC-Jo-M5e" id="gMv-Gj-Dyg"/>
<outlet property="textField_accountUID" destination="Mv3-b8-21b" id="Cxi-GZ-5oi"/>
<outlet property="textField_accountUIDLabel" destination="yae-v6-YMB" id="XHk-zX-T5y"/>
<outlet property="textField_historyRetrieveDays" destination="gKj-Oj-qll" id="tvW-aI-8ws"/>
<outlet property="textField_inactiveDaysOffline" destination="Nvv-1I-L31" id="8Sn-4f-M5j"/>
<outlet property="view_options" destination="DGa-mQ-g3C" id="L0S-pj-8w4"/>
<outlet property="view_setup" destination="c22-O7-iKe" id="xp5-o5-fb9"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe" userLabel="Setup">
<rect key="frame" x="0.0" y="0.0" width="321" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Mv3-b8-21b">
<rect key="frame" x="124" y="56" width="177" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="+491573123456" drawsBackground="YES" id="ddM-ki-WMe">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yae-v6-YMB">
<rect key="frame" x="-54" y="59" width="172" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Phone Number:" id="0UB-Dx-PpB">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MCb-6Q-kUW">
<rect key="frame" x="28" y="20" width="264" height="28"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Your phone number in the international format, a leading '+' and without any other special chars." id="2C9-SB-kKZ">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="380.5" y="76"/>
</customView>
<customView id="DGa-mQ-g3C" userLabel="Options">
<rect key="frame" x="0.0" y="0.0" width="272" height="167"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nvv-1I-L31">
<rect key="frame" x="176" y="4" width="49" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Pm0-Jw-ayL">
<numberFormatter key="formatter" formatterBehavior="default10_4" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="3" id="L9W-52-Xg9"/>
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zRH-KJ-uvC" userLabel="Accept Secret Chats">
<rect key="frame" x="6" y="34" width="160" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="Ignore history older than" id="MSN-Hj-aRS">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gKj-Oj-qll">
<rect key="frame" x="176" y="29" width="49" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="lVr-43-iAS">
<numberFormatter key="formatter" formatterBehavior="default10_4" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="3" id="tH1-pY-m7Q"/>
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<matrix verticalHuggingPriority="750" fixedFrame="YES" allowsEmptySelection="NO" autorecalculatesCellSize="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RGC-Jo-M5e">
<rect key="frame" x="176" y="103" width="76" height="58"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="76" height="18"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" inset="2" id="XXf-7E-yhf">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<cells>
<column>
<buttonCell type="radio" title="Ask" imagePosition="left" alignment="left" state="on" tag="1" inset="2" id="4By-2J-SQI">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<buttonCell type="radio" title="Always" imagePosition="left" alignment="left" inset="2" id="8dy-8R-AFa">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<buttonCell type="radio" title="Never" imagePosition="left" alignment="left" inset="2" id="nh1-0i-HQD">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</column>
</cells>
</matrix>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="m95-No-oJH" userLabel="Accept Secret Chats">
<rect key="frame" x="6" y="9" width="168" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" userInterfaceLayoutDirection="rightToLeft" alignment="left" title="Display users offline after" id="zJx-0I-fdw">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TaV-3x-dxE">
<rect key="frame" x="231" y="9" width="126" height="14"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Days" id="Aav-dA-OrQ">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sb8-oa-s84">
<rect key="frame" x="231" y="34" width="126" height="14"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Days" id="cOl-DG-CvA">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Tat-1e-jqI">
<rect key="frame" x="6" y="77" width="178" height="24"/>
<buttonCell key="cell" type="check" title="Display read notifications" bezelStyle="regularSquare" imagePosition="left" scrollable="YES" lineBreakMode="clipping" state="on" inset="2" id="l1g-r5-pNb">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Qob-Rq-UJj">
<rect key="frame" x="6" y="57" width="213" height="18"/>
<buttonCell key="cell" type="check" title="Fetch past history on first login" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="uu6-Td-pzN">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4Mf-Qx-mrn" userLabel="Accept Secret Chats">
<rect key="frame" x="6" y="144" width="135" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" userInterfaceLayoutDirection="rightToLeft" alignment="left" title="Accept secret chats?" id="t4Q-j1-35n">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="356" y="272.5"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="OjL-yD-9te"/>
</objects>
</document>

View file

@ -0,0 +1,31 @@
/*
* Adium is the legal property of its developers, whose names are listed in the copyright file included
* with this source distribution.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <Adium/AIAccountViewController.h>
#import <AdiumLibpurple/PurpleAccountViewController.h>
@interface TelegramAccountViewController : PurpleAccountViewController {
IBOutlet NSButton *checkbox_historySyncAll;
IBOutlet NSButton *checkbox_displayReadNotifications;
IBOutlet NSTextField *textField_maxMsgSplitCount;
IBOutlet NSTextField *textField_inactiveDaysOffline;
IBOutlet NSTextField *textField_historyRetrieveDays;
IBOutlet NSMatrix *radio_Encryption;
}
@end

View file

@ -0,0 +1,93 @@
/*
* Adium is the legal property of its developers, whose names are listed in the copyright file included
* with this source distribution.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "TelegramAccountViewController.h"
#import "AdiumTelegramAccount.h"
#import <Adium/AIService.h>
#import <AIUtilities/AIStringFormatter.h>
#import <AIUtilities/AIAttributedStringAdditions.h>
#import <AIUtilities/AIPopUpButtonAdditions.h>
#include "telegram-purple.h"
@implementation TelegramAccountViewController
- (NSString *)nibName{
return @"TelegramAccountView";
}
- (void)configureForAccount:(AIAccount *)inAccount
{
[super configureForAccount:inAccount];
NSString *acceptSecretChats = [account
preferenceForKey:@"Telegram:"TGP_KEY_ACCEPT_SECRET_CHATS
group:GROUP_ACCOUNT_STATUS] ?: @TGP_DEFAULT_ACCEPT_SECRET_CHATS;
NSInteger row = 0;
if ([acceptSecretChats isEqual:@"always"]) {
row = 1;
} else if ([acceptSecretChats isEqual:@"never"]) {
row = 2;
}
[radio_Encryption selectCellAtRow:row column:0];
id s = [account preferenceForKey:@"Telegram:"TGP_KEY_HISTORY_SYNC_ALL group:GROUP_ACCOUNT_STATUS];
[checkbox_historySyncAll setState:[s boolValue]];
id s4 = [account preferenceForKey:@"Telegram:"TGP_KEY_DISPLAY_READ_NOTIFICATIONS group:GROUP_ACCOUNT_STATUS];
[checkbox_displayReadNotifications setState:[s4 boolValue]];
NSString *inactiveDaysOffline = [account
preferenceForKey:@"Telegram:"TGP_KEY_INACTIVE_DAYS_OFFLINE
group:GROUP_ACCOUNT_STATUS] ?: @"";
[textField_inactiveDaysOffline setStringValue:inactiveDaysOffline];
NSString *historyRetrievalThreshold = [account
preferenceForKey:@"Telegram:"TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD
group:GROUP_ACCOUNT_STATUS] ?: @"";
[textField_historyRetrieveDays setStringValue:historyRetrievalThreshold];
}
- (void)saveConfiguration
{
[super saveConfiguration];
NSArray *selections = @[@"ask", @"always", @"never"];
[account setPreference:selections[[radio_Encryption selectedRow]]
forKey:@"Telegram:"TGP_KEY_ACCEPT_SECRET_CHATS
group:GROUP_ACCOUNT_STATUS];
[account setPreference:[NSNumber numberWithBool:[checkbox_historySyncAll state]]
forKey:@"Telegram:"TGP_KEY_HISTORY_SYNC_ALL
group:GROUP_ACCOUNT_STATUS];
[account setPreference:[NSNumber numberWithBool:[checkbox_displayReadNotifications state]]
forKey:@"Telegram:"TGP_KEY_DISPLAY_READ_NOTIFICATIONS
group:GROUP_ACCOUNT_STATUS];
[account setPreference:[textField_historyRetrieveDays stringValue]
forKey:@"Telegram:"TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD
group:GROUP_ACCOUNT_STATUS];
[account setPreference:[textField_inactiveDaysOffline stringValue]
forKey:@"Telegram:"TGP_KEY_INACTIVE_DAYS_OFFLINE
group:GROUP_ACCOUNT_STATUS];
}
@end

View file

@ -18,6 +18,7 @@
#import "TelegramService.h"
#import "AdiumTelegramAccount.h"
#import "TelegramAccountViewController.h"
#import <Adium/AIStatusControllerProtocol.h>
#import <AIUtilities/AIImageAdditions.h>
@ -28,6 +29,9 @@
return [AdiumTelegramAccount class];
}
- (AIAccountViewController *)accountViewController{
return [TelegramAccountViewController accountViewController];
}
//Service Description
- (NSString *)serviceCodeUniqueID{
return @"prpl-telegram";

View file

@ -35,6 +35,9 @@
C487A1911A792EA50044F135 /* libglib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C487A18F1A792EA50044F135 /* libglib.framework */; };
C487A1921A792EA50044F135 /* libpurple.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C487A1901A792EA50044F135 /* libpurple.framework */; };
C49A915819BBC5C5001B3DC0 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C49A915719BBC5C5001B3DC0 /* libz.dylib */; };
C4B4BE2E1AB392F80064AC17 /* TelegramAccountView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */; };
C4B4BE311AB393800064AC17 /* TelegramAccountViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4B4BE2F1AB393800064AC17 /* TelegramAccountViewController.m */; };
C4B4BE331AB4536F0064AC17 /* PurpleDefaultsTelegram.plist in Resources */ = {isa = PBXBuildFile; fileRef = C4B4BE321AB4536F0064AC17 /* PurpleDefaultsTelegram.plist */; };
C4D819031A5C85FE0044CBA9 /* lodepng.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D819011A5C85FE0044CBA9 /* lodepng.c */; };
C4D819061A5C862E0044CBA9 /* tgp-structs.c in Sources */ = {isa = PBXBuildFile; fileRef = C4D819041A5C862E0044CBA9 /* tgp-structs.c */; };
C4E528111A8A907200C4B915 /* tgp-ft.c in Sources */ = {isa = PBXBuildFile; fileRef = C4E5280F1A8A907200C4B915 /* tgp-ft.c */; };
@ -85,6 +88,10 @@
C487A18F1A792EA50044F135 /* libglib.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libglib.framework; path = Frameworks/Adium/libglib.framework; sourceTree = "<group>"; };
C487A1901A792EA50044F135 /* libpurple.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libpurple.framework; path = Frameworks/Adium/libpurple.framework; sourceTree = "<group>"; };
C49A915719BBC5C5001B3DC0 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TelegramAccountView.xib; sourceTree = "<group>"; };
C4B4BE2F1AB393800064AC17 /* TelegramAccountViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TelegramAccountViewController.m; sourceTree = "<group>"; };
C4B4BE301AB393800064AC17 /* TelegramAccountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelegramAccountViewController.h; sourceTree = "<group>"; };
C4B4BE321AB4536F0064AC17 /* PurpleDefaultsTelegram.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = PurpleDefaultsTelegram.plist; sourceTree = "<group>"; };
C4D819011A5C85FE0044CBA9 /* lodepng.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lodepng.c; sourceTree = "<group>"; };
C4D819021A5C85FE0044CBA9 /* lodepng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lodepng.h; sourceTree = "<group>"; };
C4D819041A5C862E0044CBA9 /* tgp-structs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tgp-structs.c"; path = "../tgp-structs.c"; sourceTree = "<group>"; };
@ -117,9 +124,10 @@
C410947D19BB2D7D0083BF3F = {
isa = PBXGroup;
children = (
C4B4BE321AB4536F0064AC17 /* PurpleDefaultsTelegram.plist */,
C438CE251A12BEAF00E1DA0F /* telegram22.png */,
C438CE231A12BEAF00E1DA0F /* telegram.png */,
C438CE241A12BEAF00E1DA0F /* telegram16.png */,
C438CE251A12BEAF00E1DA0F /* telegram22.png */,
C438CE261A12BEAF00E1DA0F /* telegram48.png */,
C410949919BB337A0083BF3F /* TelegramPlugin.h */,
C410949A19BB337A0083BF3F /* TelegramPlugin.m */,
@ -127,6 +135,9 @@
C4877C1719BB37EA006FA91F /* TelegramService.m */,
C4877C1C19BB676B006FA91F /* AdiumTelegramAccount.h */,
C4877C1D19BB676B006FA91F /* AdiumTelegramAccount.m */,
C4B4BE301AB393800064AC17 /* TelegramAccountViewController.h */,
C4B4BE2F1AB393800064AC17 /* TelegramAccountViewController.m */,
C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */,
C4BF990319BB8B200038D507 /* telegram-purple */,
C410948B19BB2D7D0083BF3F /* telegram-adium */,
C410948819BB2D7D0083BF3F /* Frameworks */,
@ -279,11 +290,13 @@
buildActionMask = 2147483647;
files = (
C438CE271A12BEAF00E1DA0F /* telegram.png in Resources */,
C4B4BE2E1AB392F80064AC17 /* TelegramAccountView.xib in Resources */,
C438CE281A12BEAF00E1DA0F /* telegram16.png in Resources */,
C438CE291A12BEAF00E1DA0F /* telegram22.png in Resources */,
C438CE2A1A12BEAF00E1DA0F /* telegram48.png in Resources */,
C410949019BB2D7D0083BF3F /* InfoPlist.strings in Resources */,
C438CE3D1A12C15100E1DA0F /* tg-server.pub in Resources */,
C4B4BE331AB4536F0064AC17 /* PurpleDefaultsTelegram.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -303,6 +316,7 @@
C4E528111A8A907200C4B915 /* tgp-ft.c in Sources */,
C438CE361A12C07800E1DA0F /* tgp-timers.c in Sources */,
C410949B19BB337A0083BF3F /* TelegramPlugin.m in Sources */,
C4B4BE311AB393800064AC17 /* TelegramAccountViewController.m in Sources */,
C4877C1E19BB676B006FA91F /* AdiumTelegramAccount.m in Sources */,
C41D58411A16D88E00B22448 /* tgp-2prpl.c in Sources */,
C425F9181A7069C300361AFC /* tgp-utils.c in Sources */,

View file

@ -815,32 +815,29 @@ static void tgprpl_init (PurplePlugin *plugin) {
ADD_VALUE(verification_values, "Always", "always");
ADD_VALUE(verification_values, "Never", "never");
opt = purple_account_option_list_new ("Accept Secret Chats", "accept-secret-chats", verification_values);
opt = purple_account_option_list_new ("Accept Secret Chats",
TGP_KEY_ACCEPT_SECRET_CHATS,
verification_values);
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, opt);
opt = purple_account_option_int_new ("Display users not seen for (N) days as offline",
"inactive-days-offline",
TGP_DEFAULT_INACTIVE_DAYS_OFFLINE);
opt = purple_account_option_int_new ("Display peers offline after (days)",
TGP_KEY_INACTIVE_DAYS_OFFLINE,
TGP_DEFAULT_INACTIVE_DAYS_OFFLINE);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_int_new ("Split oversized messages in up to (N) chunks",
"max-msg-split-count",
TGP_DEFAULT_MAX_MSG_SPLIT_COUNT);
opt = purple_account_option_bool_new ("Fetch past history on first login",
TGP_KEY_HISTORY_SYNC_ALL,
TGP_DEFAULT_HISTORY_SYNC_ALL);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_int_new ("Don't fetch messages older than (N) days\n"
opt = purple_account_option_int_new ("Don't fetch messages older than (days)\n"
"(0 for unlimited)",
"history-retrieve-days",
TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD,
TGP_DEFAULT_HISTORY_RETRIEVAL_THRESHOLD);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_bool_new ("Fetch past history on first login "
"(Warning, can be slow)",
"history-sync-all", FALSE);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);
opt = purple_account_option_bool_new ("Display read notifications (annoying)",
"display-read-notifications",
opt = purple_account_option_bool_new ("Display read notifications",
TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD,
TGP_DEFAULT_DISPLAY_READ_NOTIFICATIONS);
prpl_info.protocol_options = g_list_append (prpl_info.protocol_options, opt);

View file

@ -37,11 +37,22 @@
#define TGP_APP_ID 16154
#define TGP_MAX_MSG_SIZE 4096
#define TGP_DEFAULT_INACTIVE_DAYS_OFFLINE 7
#define TGP_DEFAULT_DISPLAY_READ_NOTIFICATIONS FALSE
#define TGP_DEFAULT_MAX_MSG_SPLIT_COUNT 4
#define TGP_DEFAULT_HISTORY_RETRIEVAL_THRESHOLD 14
#define TGP_DEFAULT_ACCEPT_SECRET_CHATS "ask"
#define TGP_KEY_ACCEPT_SECRET_CHATS "accept-secret-chats"
#define TGP_DEFAULT_INACTIVE_DAYS_OFFLINE 7
#define TGP_KEY_INACTIVE_DAYS_OFFLINE "inactive-days-offline"
#define TGP_DEFAULT_DISPLAY_READ_NOTIFICATIONS FALSE
#define TGP_KEY_DISPLAY_READ_NOTIFICATIONS "display-read-notifications"
#define TGP_DEFAULT_HISTORY_RETRIEVAL_THRESHOLD 14
#define TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD "history-retrieve-days"
#define TGP_KEY_HISTORY_SYNC_ALL "history-sync-all"
#define TGP_DEFAULT_HISTORY_SYNC_ALL FALSE
void on_chat_get_info (struct tgl_state *TLS, void *extra, int success, struct tgl_chat *C);
void on_ready (struct tgl_state *TLS);

View file

@ -162,9 +162,7 @@ static void tgp_msg_send_done (struct tgl_state *TLS, void *callback_extra, int
}
static int tgp_msg_send_split (struct tgl_state *TLS, const char *message, tgl_peer_id_t to) {
connection_data *data = TLS->ev_base;
int max = purple_account_get_int (data->pa, "max-msg-split-count",
TGP_DEFAULT_MAX_MSG_SPLIT_COUNT);
int max = TGP_DEFAULT_MAX_MSG_SPLIT_COUNT;
if (max < 1) {
max = 1;
}