Skip to content

Commit afd20b7

Browse files
committed
Libezv import and compilable.
1 parent e17043e commit afd20b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+10324
-3
lines changed

iChatBridge/iChatBridge.xcodeproj/project.pbxproj

+201
Large diffs are not rendered by default.

iChatBridge/iChatBridge/BonjourManager.m iChatBridge/iChatBridge/Classes/BonjourManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ - (void) login
136136
dnsError = DNSServiceRegister(
137137
/* Uninitialized service discovery reference */ &servRef,
138138
/* Flags indicating how to handle name conflicts */ /* kDNSServiceFlagsNoAutoRename */ 0,
139-
/* Interface on which to register, 0 for all available */ 0,
139+
/* Interface on which to register, 0 for all available */ kDNSServiceInterfaceIndexLocalOnly,
140140
/* Service's name, may be null */ [avInstanceName UTF8String],
141141
/* Service registration type */ "_presence._tcp",
142142
/* Domain, may be NULL */ NULL,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// NSString+icb.h
3+
// iChatBridge
4+
//
5+
// Created by Jerry Hsu on 3/20/12.
6+
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface NSString (icb)
12+
13+
+ (id) stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding;
14+
+ (id)ellipsis;
15+
16+
- (NSString *)stringByAppendingEllipsis;
17+
- (NSString *)stringWithEllipsisByTruncatingToLength:(NSUInteger)length;
18+
19+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// NSString+icb.m
3+
// iChatBridge
4+
//
5+
// Created by Jerry Hsu on 3/20/12.
6+
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import "NSString+icb.h"
10+
11+
@implementation NSString (icb)
12+
13+
+ (id)stringWithData:(NSData *)data encoding:(NSStringEncoding)encoding
14+
{
15+
return [[[self alloc] initWithData:data encoding:encoding] autorelease];
16+
}
17+
18+
+ (id)ellipsis
19+
{
20+
return [self stringWithUTF8String:"\xE2\x80\xA6"];
21+
}
22+
23+
- (NSString *)stringByAppendingEllipsis
24+
{
25+
return [self stringByAppendingString:[NSString stringWithUTF8String:"\xE2\x80\xA6"]];
26+
}
27+
28+
- (NSString *)stringWithEllipsisByTruncatingToLength:(NSUInteger)length
29+
{
30+
NSString *returnString;
31+
32+
if (length < [self length]) {
33+
//Truncate and append the ellipsis
34+
returnString = [[self substringToIndex:length-1] stringByAppendingString:[NSString ellipsis]];
35+
} else {
36+
//We don't need to truncate, so don't append an ellipsis
37+
returnString = [[self copy] autorelease];
38+
}
39+
40+
return (returnString);
41+
}
42+
@end

iChatBridge/iChatBridge/ICBAppDelegate.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
77
//
88
#import <Foundation/Foundation.h>
9-
#import "AWEzvRendezvousData.h"
10-
#import "BonjourManager.h"
119
#import "ICBAppDelegate.h"
10+
#import "AWEzvRendezvousData.h"
1211

1312
@implementation ICBAppDelegate
1413

Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Project: Libezv
3+
* File: AWEzv.h
4+
*
5+
* Version: 1.0
6+
* Author: Andrew Wellington <proton[at]wiretapped.net>
7+
*
8+
* License:
9+
* Copyright (C) 2004-2005 Andrew Wellington.
10+
* All rights reserved.
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions are met:
14+
*
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
* 2. Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and/or other materials provided with the distribution.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
22+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
24+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
#import "AWEzvDefines.h"
34+
#import "EKEzvOutgoingFileTransfer.h"
35+
36+
@class AWEzvContact, AWEzvContactManager;
37+
38+
@protocol AWEzvClientProtocol <NSObject>
39+
- (void) reportLoggedIn;
40+
- (void) reportLoggedOut;
41+
- (void) userLoggedOut:(AWEzvContact *)contact;
42+
- (void) userChangedState:(AWEzvContact *)contact;
43+
- (void) userChangedImage:(AWEzvContact *)contact;
44+
- (void) user:(AWEzvContact *)contact sentMessage:(NSString *)message withHtml:(NSString *)html;
45+
- (void) user:(AWEzvContact *)contact typingNotification:(AWEzvTyping)typingStatus;
46+
- (void) user:(AWEzvContact *)contact typeAhead:(NSString *)message withHtml:(NSString *)html;
47+
48+
// File Transfer
49+
- (void)updateProgressForFileTransfer:(EKEzvFileTransfer *)fileTransfer percent:(NSNumber *)percent bytesSent:(NSNumber *)bytesSent;
50+
- (void)remoteCanceledFileTransfer:(EKEzvFileTransfer *)fileTransfer;
51+
- (void)transferFailed:(EKEzvFileTransfer *)fileTransfer;
52+
// Incoming File Transfer
53+
- (void)user:(AWEzvContact *)contact sentFile:(EKEzvFileTransfer *)fileTransfer;
54+
// Outgoing File Transfer
55+
- (void)remoteUserBeganDownload:(EKEzvOutgoingFileTransfer *)fileTransfer;
56+
- (void)remoteUserFinishedDownload:(EKEzvOutgoingFileTransfer *)fileTransfer;
57+
58+
- (void) reportError:(NSString *)error ofLevel:(AWEzvErrorSeverity)severity;
59+
- (void) reportError:(NSString *)error ofLevel:(AWEzvErrorSeverity)severity forUser:(NSString *)contact;
60+
61+
@end
62+
63+
@interface AWEzv : NSObject {
64+
id <AWEzvClientProtocol> client;
65+
AWEzvContactManager *manager;
66+
67+
NSString *name;
68+
AWEzvStatus status;
69+
NSDate *idleTime;
70+
}
71+
72+
- (id) initWithClient:(id <AWEzvClientProtocol, NSObject>)newClient;
73+
74+
- (void) login;
75+
- (void) logout;
76+
- (id <AWEzvClientProtocol, NSObject>) client;
77+
- (void) sendMessage:(NSString *)message to:(NSString *)contact withHtml:(NSString *)html;
78+
- (void) sendTypingNotification:(AWEzvTyping)typingStatus to:(NSString*)contact;
79+
- (void) sendTypeAhead:(NSString *)message to:(NSString *)contact withHtml:(NSString *)html;
80+
- (void) setName:(NSString *)name;
81+
- (void) setStatus:(AWEzvStatus)status withMessage:(NSString *)message;
82+
- (void) setIdleTime:(NSDate *)date;
83+
- (void) setContactImageData:(NSData *)contactImage;
84+
- (AWEzvContact *) contactForIdentifier:(NSString *)uniqueID;
85+
86+
// This API is subject to change
87+
- (void) sendFile:(NSString *)filename to:(NSString *)contact size:(size_t)size;
88+
89+
- (void) startOutgoingFileTransfer:(EKEzvOutgoingFileTransfer *)transfer;
90+
- (void)transferCancelled:(EKEzvFileTransfer *)transfer;
91+
- (void) transferAccepted:(EKEzvFileTransfer *)transfer withFileName:(NSString *)fileName;
92+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Project: Libezv
3+
* File: AWEzv.m
4+
*
5+
* Version: 1.0
6+
* Author: Andrew Wellington <proton[at]wiretapped.net>
7+
*
8+
* License:
9+
* Copyright (C) 2004-2007 Andrew Wellington.
10+
* All rights reserved.
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions are met:
14+
*
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
* 2. Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and/or other materials provided with the distribution.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
22+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
24+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
#import "AWEzv.h"
34+
35+
#import "AWEzvContact.h"
36+
37+
#import "EKEzvFileTransfer.h"
38+
#import "EKEzvOutgoingFileTransfer.h"
39+
40+
/* Private classes - libezv use only */
41+
#import "AWEzvContactManager.h"
42+
#import "AWEzvContactManagerRendezvous.h"
43+
#import "AWEzvContactManagerListener.h"
44+
45+
#import "AWEzvSupportRoutines.h"
46+
47+
@implementation AWEzv
48+
- (id) initWithClient:(id <AWEzvClientProtocol, NSObject>)newClient
49+
{
50+
if ((self = [super init])) {
51+
client = newClient;
52+
name = nil;
53+
status = AWEzvUndefined;
54+
}
55+
56+
return self;
57+
}
58+
59+
- (void) dealloc {
60+
//Ensure we log out before deallocing
61+
[self logout];
62+
63+
[manager release];
64+
[super dealloc];
65+
}
66+
67+
- (id <AWEzvClientProtocol, NSObject>) client {
68+
return client;
69+
}
70+
71+
- (void) login {
72+
manager = [(AWEzvContactManager *)[AWEzvContactManager alloc] initWithClient:self];
73+
[manager listen];
74+
[manager login];
75+
}
76+
77+
- (void) setName:(NSString *)newName {
78+
if (name != newName) {
79+
[name release];
80+
name = [newName retain];
81+
[manager updatedName];
82+
}
83+
}
84+
- (void) setStatus:(AWEzvStatus)newStatus withMessage:(NSString *)message{
85+
status = newStatus;
86+
[manager setStatus:status withMessage:message];
87+
}
88+
89+
- (void) setIdleTime:(NSDate *)date {
90+
if (idleTime)
91+
[idleTime release];
92+
93+
if (!date) {
94+
idleTime = nil;
95+
status = AWEzvOnline;
96+
} else {
97+
idleTime = [date retain];
98+
status = AWEzvIdle;
99+
}
100+
[manager updatedStatus];
101+
}
102+
103+
- (void) sendMessage:(NSString *)message to:(NSString *)uniqueId withHtml:(NSString *)html {
104+
AWEzvContact *contact;
105+
106+
contact = [manager contactForIdentifier:uniqueId];
107+
[contact sendMessage:message withHtml:html];
108+
}
109+
110+
- (void) setContactImageData:(NSData *)contactImage {
111+
[manager setImageData: contactImage];
112+
}
113+
114+
- (void) sendTypingNotification:(AWEzvTyping)typingStatus to:(NSString *)uniqueId {
115+
AWEzvContact *contact;
116+
117+
contact = [manager contactForIdentifier:uniqueId];
118+
if (contact != nil) {
119+
[contact sendTypingNotification:typingStatus];
120+
}
121+
}
122+
123+
- (void) sendTypeAhead:(NSString *)message to:(NSString *)contact withHtml:(NSString *)html {
124+
/* Not implemented yet */
125+
}
126+
127+
- (void) logout
128+
{
129+
// NSLog(@"Manager is %@", manager);
130+
[manager logout];
131+
[manager stopListening];
132+
[manager stopBrowsing];
133+
[manager closeConnections];
134+
}
135+
136+
- (void) sendFile:(NSString *)filename to:(NSString *)contact size:(size_t)size
137+
{
138+
/* Not implemented yet */
139+
}
140+
- (void) startOutgoingFileTransfer:(EKEzvOutgoingFileTransfer *)transfer
141+
{
142+
[transfer setManager:manager];
143+
[transfer startSending];
144+
}
145+
146+
- (void) transferAccepted:(EKEzvFileTransfer *)transfer withFileName:(NSString *)fileName{
147+
/* Tell the EKEZvFileTransfer object to download!! */
148+
[transfer setLocalFilename: fileName];
149+
[transfer begin];
150+
151+
}
152+
- (void)transferCancelled:(EKEzvFileTransfer *)transfer{
153+
[transfer cancel];
154+
}
155+
156+
- (AWEzvContact *)contactForIdentifier:(NSString *)uniqueID {
157+
return [manager contactForIdentifier:uniqueID];
158+
}
159+
160+
@end

0 commit comments

Comments
 (0)