Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
88f13ea2
Kaydet (Commit)
88f13ea2
authored
Haz 04, 2013
tarafından
siqi
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
communication files
üst
85be4cc4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
275 additions
and
0 deletions
+275
-0
.DS_Store
ios/iosremote/iosremote/Communication/.DS_Store
+0
-0
Client.h
ios/iosremote/iosremote/Communication/Client.h
+25
-0
Client.m
ios/iosremote/iosremote/Communication/Client.m
+139
-0
CommunicationManager.h
ios/iosremote/iosremote/Communication/CommunicationManager.h
+13
-0
CommunicationManager.m
ios/iosremote/iosremote/Communication/CommunicationManager.m
+13
-0
Receiver.h
ios/iosremote/iosremote/Communication/Receiver.h
+13
-0
Receiver.m
ios/iosremote/iosremote/Communication/Receiver.m
+13
-0
Server.h
ios/iosremote/iosremote/Communication/Server.h
+23
-0
Server.m
ios/iosremote/iosremote/Communication/Server.m
+36
-0
No files found.
ios/iosremote/iosremote/Communication/.DS_Store
0 → 100644
Dosyayı görüntüle @
88f13ea2
File added
ios/iosremote/iosremote/Communication/Client.h
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Client.h
//
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Server.h"
#import "CommunicationManager.h"
#import "Receiver.h"
@interface
Client
:
NSObject
-
(
void
)
connect
;
-
(
id
)
initWithServer
:(
Server
*
)
server
managedBy
:(
CommunicationManager
*
)
manager
interpretedBy
:(
Receiver
*
)
receiver
;
-
(
void
)
stream
:(
NSStream
*
)
stream
handleEvent
:(
NSStreamEvent
)
eventCode
;
@end
\ No newline at end of file
ios/iosremote/iosremote/Communication/Client.m
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Client.m
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "Client.h"
#import "Server.h"
#import "Receiver.h"
#import "CommunicationManager.h"
@interface
Client
()
<
NSStreamDelegate
>
@property
(
nonatomic
,
strong
)
NSInputStream
*
mInputStream
;
@property
(
nonatomic
,
strong
)
NSOutputStream
*
mOutputStream
;
@property
(
nonatomic
,
strong
)
NSString
*
mPin
;
@property
(
nonatomic
,
strong
)
NSString
*
mName
;
@property
uint
mPort
;
@property
(
nonatomic
,
weak
)
Server
*
mServer
;
@property
(
nonatomic
,
weak
)
Receiver
*
mReceiver
;
@property
(
nonatomic
,
weak
)
CommunicationManager
*
mComManager
;
@property
(
nonatomic
,
retain
)
NSMutableData
*
mData
;
@property
BOOL
mReady
;
@end
@implementation
Client
@synthesize
mInputStream
=
_mInputStream
;
@synthesize
mOutputStream
=
_mOutputStream
;
@synthesize
mPin
=
_mPin
;
@synthesize
mName
=
_mName
;
@synthesize
mServer
=
_mServer
;
@synthesize
mComManager
=
_mComManager
;
@synthesize
mData
=
_mData
;
@synthesize
mReady
=
_mReady
;
NSString
*
const
CHARSET
=
@"UTF-8"
;
-
(
id
)
initWithServer
:(
Server
*
)
server
managedBy
:(
CommunicationManager
*
)
manager
interpretedBy
:(
Receiver
*
)
receiver
{
self
.
mPin
=
@""
;
self
.
mName
=
server
.
serverName
;
self
.
mComManager
=
manager
;
self
.
mReceiver
=
receiver
;
// hardcoded here to test the communication TODO
self
.
mPort
=
1599
;
return
self
;
}
-
(
void
)
streamOpenWithIp
:(
NSString
*
)
ip
withPortNumber
:(
uint
)
portNumber
{
NSLog
(
@"Connecting to %@:%u"
,
ip
,
portNumber
);
CFReadStreamRef
readStream
;
CFWriteStreamRef
writeStream
;
CFStreamCreatePairWithSocketToHost
(
kCFAllocatorDefault
,
(
__bridge
CFStringRef
)
ip
,
portNumber
,
&
readStream
,
&
writeStream
);
if
(
readStream
&&
writeStream
)
{
CFReadStreamSetProperty
(
readStream
,
kCFStreamPropertyShouldCloseNativeSocket
,
kCFBooleanTrue
);
CFWriteStreamSetProperty
(
writeStream
,
kCFStreamPropertyShouldCloseNativeSocket
,
kCFBooleanTrue
);
//Setup mInputStream
self
.
mInputStream
=
(
__bridge
NSInputStream
*
)
readStream
;
[
self
.
mInputStream
setDelegate
:
self
];
[
self
.
mInputStream
scheduleInRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:
NSDefaultRunLoopMode
];
[
self
.
mInputStream
open
];
//Setup outputstream
self
.
mOutputStream
=
(
__bridge
NSOutputStream
*
)
writeStream
;
[
self
.
mOutputStream
setDelegate
:
self
];
[
self
.
mOutputStream
scheduleInRunLoop
:[
NSRunLoop
currentRunLoop
]
forMode
:
NSDefaultRunLoopMode
];
[
self
.
mOutputStream
open
];
}
NSLog
(
@"Connected"
);
}
-
(
void
)
sendCommand
:(
NSString
*
)
aCommand
{
// UTF-8 as speficied in specification
NSData
*
data
=
[
aCommand
dataUsingEncoding
:
NSUTF8StringEncoding
];
[
self
.
mOutputStream
write
:(
uint8_t
*
)[
data
bytes
]
maxLength
:[
data
length
]];
}
-
(
void
)
stream
:(
NSStream
*
)
stream
handleEvent
:(
NSStreamEvent
)
eventCode
{
switch
(
eventCode
)
{
case
NSStreamEventHasBytesAvailable
:
{
if
(
!
self
.
mData
)
{
self
.
mData
=
[
NSMutableData
data
];
}
uint8_t
buf
[
1024
];
unsigned
int
len
=
0
;
len
=
[(
NSInputStream
*
)
stream
read
:
buf
maxLength
:
1024
];
if
(
len
)
{
[
self
.
mData
appendBytes
:(
const
void
*
)
buf
length
:
len
];
int
bytesRead
=
0
;
// bytesRead is an instance variable of type NSNumber.
bytesRead
+=
len
;
}
else
{
NSLog
(
@"No data but received event for whatever reasons!"
);
}
NSString
*
str
=
[[
NSString
alloc
]
initWithData
:
self
.
mData
encoding
:
NSUTF8StringEncoding
];
NSLog
(
@"Data Received: %@"
,
str
);
self
.
mData
=
nil
;
}
break
;
default:
{
}
}
}
-
(
void
)
connect
{
[
self
streamOpenWithIp
:
self
.
mServer
.
serverAddress
withPortNumber
:
self
.
mPort
];
}
@end
ios/iosremote/iosremote/Communication/CommunicationManager.h
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// CommunicationManager.h
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface
CommunicationManager
:
NSObject
@end
ios/iosremote/iosremote/Communication/CommunicationManager.m
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// CommunicationManager.m
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "CommunicationManager.h"
@implementation
CommunicationManager
@end
ios/iosremote/iosremote/Communication/Receiver.h
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Receiver.h
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface
Receiver
:
NSObject
@end
ios/iosremote/iosremote/Communication/Receiver.m
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Receiver.m
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "Receiver.h"
@implementation
Receiver
@end
ios/iosremote/iosremote/Communication/Server.h
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Server.h
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef
enum
protocol
{
NETWORK
}
Protocol_t
;
@interface
Server
:
NSObject
@property
(
nonatomic
)
Protocol_t
protocol
;
@property
(
nonatomic
,
strong
)
NSString
*
serverName
;
@property
(
nonatomic
,
strong
)
NSString
*
serverAddress
;
-
(
id
)
initWithProtocol
:(
Protocol_t
)
protocal
atAddress
:(
NSString
*
)
address
ofName
:
(
NSString
*
)
name
;
@end
ios/iosremote/iosremote/Communication/Server.m
0 → 100644
Dosyayı görüntüle @
88f13ea2
//
// Server.m
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "Server.h"
@interface
Server
()
@end
@implementation
Server
@synthesize
protocol
=
_protocol
;
@synthesize
serverName
=
_serverName
;
@synthesize
serverAddress
=
_serverAddress
;
-
(
id
)
initWithProtocol
:(
Protocol_t
)
protocal
atAddress
:(
NSString
*
)
address
ofName
:
(
NSString
*
)
name
{
self
=
[
self
init
];
self
.
protocol
=
protocal
;
self
.
serverAddress
=
address
;
self
.
serverName
=
name
;
return
self
;
}
-
(
NSString
*
)
description
{
return
[
NSString
stringWithFormat
:
@"Server: Name:%@ Addr:%@"
,
self
.
serverName
,
self
.
serverAddress
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment