Add basic chat join view for the Adium Plugin

This commit is contained in:
mjentsch 2015-03-18 22:33:26 +01:00
parent a0700adeb0
commit 9838eb7b85
7 changed files with 150 additions and 5 deletions

View file

@ -49,7 +49,7 @@
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="380.5" y="76"/>
<point key="canvasLocation" x="380.5" y="13"/>
</customView>
<customView id="DGa-mQ-g3C" userLabel="Options">
<rect key="frame" x="0.0" y="0.0" width="272" height="167"/>
@ -84,7 +84,7 @@
<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="cellSize" width="66" 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"/>
@ -154,7 +154,7 @@
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="356" y="272.5"/>
<point key="canvasLocation" x="356" y="201.5"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="OjL-yD-9te"/>
</objects>

View file

@ -0,0 +1,40 @@
<?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="TelegramJoinChatViewController">
<connections>
<outlet property="textField_roomName" destination="EKe-0P-EsS" id="afm-T6-MsZ"/>
<outlet property="view" destination="c22-O7-iKe" id="4pN-H1-fp0"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="265" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="EKe-0P-EsS">
<rect key="frame" x="87" y="6" width="172" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="4Jc-ER-I2m">
<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="qUU-2Z-89E">
<rect key="frame" x="3" y="6" width="78" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Chat Name:" id="Muj-XM-wKR">
<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="313.5" y="332.5"/>
</customView>
</objects>
</document>

View file

@ -0,0 +1,25 @@
/*
* 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/DCJoinChatViewController.h>
@class AIAccount, AICompletingTextField;
@interface TelegramJoinChatViewController : DCJoinChatViewController {
IBOutlet NSTextField *textField_roomName;
}
@end

View file

@ -0,0 +1,51 @@
/*
* 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.
*/
#include <tgl.h>
#include "TelegramJoinChatViewController.h"
#import <Adium/AIContactControllerProtocol.h>
#import <AIUtilities/AICompletingTextField.h>
#import <Adium/AIListContact.h>
#import <Adium/AIWindowController.h>
@interface NSObject (JointChatViewDelegate)
- (void)setJoinChatEnabled:(BOOL)enabled;
@end
@implementation TelegramJoinChatViewController
- (void)joinChatWithAccount:(AIAccount *)inAccount
{
NSString *room = [textField_roomName stringValue];
NSDictionary *chatCreationInfo = [NSDictionary
dictionaryWithObjectsAndKeys:room, @"subject", nil];
[self doJoinChatWithName:room
onAccount:inAccount
chatCreationInfo:chatCreationInfo
invitingContacts:@[]
withInvitationMessage:@""];
}
- (NSString *)nibName
{
return @"TelegramJoinChatView";
}
@end

View file

@ -19,6 +19,7 @@
#import "TelegramService.h"
#import "AdiumTelegramAccount.h"
#import "TelegramAccountViewController.h"
#import "TelegramJoinChatViewController.h"
#import <Adium/AIStatusControllerProtocol.h>
#import <AIUtilities/AIImageAdditions.h>
@ -32,6 +33,11 @@
- (AIAccountViewController *)accountViewController{
return [TelegramAccountViewController accountViewController];
}
- (DCJoinChatViewController *)joinChatView{
return [TelegramJoinChatViewController joinChatView];
}
//Service Description
- (NSString *)serviceCodeUniqueID{
return @"prpl-telegram";

View file

@ -38,6 +38,8 @@
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 */; };
C4B4BE371AB5FB5C0064AC17 /* TelegramJoinChatViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4B4BE351AB5FB5C0064AC17 /* TelegramJoinChatViewController.m */; };
C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */; };
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 */; };
@ -92,6 +94,9 @@
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>"; };
C4B4BE351AB5FB5C0064AC17 /* TelegramJoinChatViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TelegramJoinChatViewController.m; sourceTree = "<group>"; };
C4B4BE361AB5FB5C0064AC17 /* TelegramJoinChatViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TelegramJoinChatViewController.h; sourceTree = "<group>"; };
C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TelegramJoinChatView.xib; 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>"; };
@ -135,6 +140,9 @@
C4877C1719BB37EA006FA91F /* TelegramService.m */,
C4877C1C19BB676B006FA91F /* AdiumTelegramAccount.h */,
C4877C1D19BB676B006FA91F /* AdiumTelegramAccount.m */,
C4B4BE361AB5FB5C0064AC17 /* TelegramJoinChatViewController.h */,
C4B4BE351AB5FB5C0064AC17 /* TelegramJoinChatViewController.m */,
C4B4BE381AB613950064AC17 /* TelegramJoinChatView.xib */,
C4B4BE301AB393800064AC17 /* TelegramAccountViewController.h */,
C4B4BE2F1AB393800064AC17 /* TelegramAccountViewController.m */,
C4B4BE2D1AB392F80064AC17 /* TelegramAccountView.xib */,
@ -290,6 +298,7 @@
buildActionMask = 2147483647;
files = (
C438CE271A12BEAF00E1DA0F /* telegram.png in Resources */,
C4B4BE391AB613950064AC17 /* TelegramJoinChatView.xib in Resources */,
C4B4BE2E1AB392F80064AC17 /* TelegramAccountView.xib in Resources */,
C438CE281A12BEAF00E1DA0F /* telegram16.png in Resources */,
C438CE291A12BEAF00E1DA0F /* telegram22.png in Resources */,
@ -310,6 +319,7 @@
C438CE321A12C07800E1DA0F /* msglog.c in Sources */,
C438CE351A12C07800E1DA0F /* tgp-net.c in Sources */,
C438CE331A12C07800E1DA0F /* telegram-base.c in Sources */,
C4B4BE371AB5FB5C0064AC17 /* TelegramJoinChatViewController.m in Sources */,
C438CE341A12C07800E1DA0F /* telegram-purple.c in Sources */,
C4877C1819BB37EA006FA91F /* TelegramService.m in Sources */,
C448ADA71AB0789A001B7ECD /* tgp-msg.c in Sources */,

View file

@ -645,11 +645,24 @@ static void tgprpl_remove_buddy (PurpleConnection * gc, PurpleBuddy * buddy, Pur
static void tgprpl_chat_join (PurpleConnection * gc, GHashTable * data) {
debug ("tgprpl_chat_join()");
const char *subject = NULL;
gpointer value;
connection_data *conn = purple_connection_get_protocol_data (gc);
gpointer value = g_hash_table_lookup (data, "id");
value = g_hash_table_lookup (data, "id");
if (value && atoi (value)) {
chat_show (conn->gc, atoi (value));
return;
}
subject = g_hash_table_lookup(data, "subject");
if (str_not_empty (subject)) {
tgl_peer_t *P = tgl_peer_get_by_name (conn->TLS, subject);
if (P && tgl_get_peer_type (P->id) == TGL_PEER_CHAT) {
chat_show (conn->gc, tgl_get_peer_id (P->id));
return;
}
debug ("Peer with name %s not found or not a chat.", subject);
}
}