~ubuntuone-ios-client-team/ubuntuone-ios-contacts/trunk

« back to all changes in this revision

Viewing changes to musicstreaming/utilities/Subsonic.m

  • Committer: Jason Foreman
  • Date: 2011-06-16 18:33:42 UTC
  • mfrom: (191.1.60 master)
  • Revision ID: jason.foreman@canonical.com-20110616183342-vl7a4804xsf0s1b5
Merging branches for v 2.0.

lp:~threeve/ubuntuone-ios-client/master
lp:~urbanape/ubuntuone-ios-client/downloader

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <netdb.h>
24
24
#include <arpa/inet.h>
25
25
#import "NSMutableSet+Extras.h"
 
26
#import "Reachability.h"
 
27
 
 
28
@interface Subsonic ()
 
29
@property (readwrite, retain) Reachability *reachability;
 
30
@end
 
31
 
26
32
 
27
33
@implementation Subsonic
28
34
@synthesize credsURL, defaultURL, defaultUserName, defaultPassword, cachedIP, cachedIPHour;
29
 
 
 
35
@synthesize reachability;
30
36
@dynamic hasCredentials;
31
37
 
32
38
SYNTHESIZE_SINGLETON_FOR_CLASS(Subsonic);
36
42
        if ((self = [super init]))
37
43
        {
38
44
        self.defaultURL = @"https://streaming.one.ubuntu.com/rest";
 
45
//        self.defaultURL = @"http://10.59.1.19:35204/musicstreaming/rest";
39
46
        self.credsURL = @"https://one.ubuntu.com/phones/creds/ios?scheme=x-ubuntuone-music";
 
47
//        self.credsURL = @"http://10.59.1.19:41858/phones/creds/ios?scheme=x-ubuntuone-music";
 
48
                self.reachability = [Reachability reachabilityWithHostName:[[NSURL URLWithString:self.defaultURL] host]];
 
49
                [self.reachability startNotifer];
40
50
        }
41
51
        return self;
42
52
}
43
53
 
 
54
- (void)dealloc;
 
55
{
 
56
        self.defaultURL = nil;
 
57
        self.credsURL = nil;
 
58
        [self.reachability stopNotifer];
 
59
        self.reachability = nil;
 
60
        [super dealloc];
 
61
}
 
62
 
44
63
- (BOOL)hasCredentials
45
64
{
46
65
        NSString *username = [SFHFKeychainUtils getPasswordForUsername:UBUNTU_ONE_DUMMY_USER_NAME andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil];
105
124
                [params addKeyValueObjectFromArray:[NSArray arrayWithObjects:@"v", @"1.1.0", nil]];
106
125
                [params addKeyValueObjectFromArray:[NSArray arrayWithObjects:@"c", @"iSub", nil]];
107
126
        
108
 
                return [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@?%@", self.defaultURL, action, [params urlEncodedString]]];
 
127
                NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@?%@", self.defaultURL, action, [params urlEncodedString]]];
 
128
        NSLog(@"URL generated: %@", url);
 
129
        return url;
109
130
        }
110
131
        else
111
132
        {