public
Description: An OS X application to build a standalone web site as an export from my photo album.
Homepage: http://bleu.west.spy.net/~dustin/projects/photosync/
Clone URL: git://github.com/dustin/photosync.git
dustin (author)
Sat Apr 05 13:41:45 -0700 2008
commit  9f8e5028800371f034fa82b2feffe677e95a86ce
tree    554ee7c313efd6d9d03ac539d2a23292a62fd6fa
parent  2dceca4018192b712c3dcbd872354326347bca00
photosync / Location.m
100644 183 lines (159 sloc) 2.781 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//
// Location.m
// PhotoSync
//
// Created by Dustin Sallings on 2005/2/1.
// Copyright 2005 Dustin Sallings. All rights reserved.
//
 
#import "Location.h"
 
@implementation Location
 
-init
{
  id rv=[super init];
  _active = YES;
  _url=@"";
  _username=@"";
  _password=@"";
  _forUser=@"";
  _destDir=@"";
 
  return rv;
}
 
-(NSString *)urlinfo
{
  NSMutableString *rv=[[NSMutableString alloc] initWithCapacity:64];
  // Leave it blank if we don't have a URL yet.
  if(_url != nil && [_url length] > 0) {
    NSString *un=_username;
    if(un == nil || [un length] == 0) {
      un=@"guest";
    }
    [rv appendFormat:@"%@@%@", un, _url];
    if(_forUser != nil && [_forUser length] > 0) {
      [rv appendFormat:@" (for %@)", _forUser];
    }
  }
  [rv autorelease];
  return(rv);
}
 
-(NSString *)description
{
  return([NSString stringWithFormat:@"<Location url=``%@'' dest=``%@''>",
    _url, _destDir]);
}
 
-initWithDict:(NSDictionary *)d
{
  self=[super init];
  _active = [[d objectForKey:@"active"] boolValue];
  _url=[[d objectForKey:@"url"] retain];
  _username=[[d objectForKey:@"username"] retain];
  _password=[[d objectForKey:@"password"] retain];
  _forUser=[[d objectForKey:@"forUser"] retain];
  _destDir=[[d objectForKey:@"destDir"] retain];
  
  return self;
}
 
-(NSDictionary *)toDict
{
  NSDictionary *rv=[NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool: _active], @"active",
    _url, @"url",
    _username, @"username",
    _password, @"password",
    _forUser, @"forUser",
    _destDir, @"destDir",
    nil];
  return(rv);
}
 
-(void)dealloc
{
  NSLog(@"Deallocing %@", self);
  if(_url != nil) {
    [_url release];
    _url=nil;
  }
  if(_username != nil) {
    [_username release];
    _username=nil;
  }
  if(_password != nil) {
    [_password release];
    _password=nil;
  }
  if(_forUser != nil) {
    [_forUser release];
    _forUser=nil;
  }
  if(_destDir != nil) {
    [_destDir release];
    _destDir=nil;
  }
  [super dealloc];
}
 
-(BOOL)isActive
{
  return _active;
}
 
-(void)setActive:(BOOL)to
{
  _active = to;
}
 
-(NSString *)url
{
  return _url;
}
 
-(void)setUrl:(NSString *)to
{
  if(_url != nil) {
    [_url release];
  }
  [to retain];
  _url = to;
}
 
-(NSString *)username
{
  return _username;
}
 
-(void)setUsername:(NSString *)to
{
  if(_username != nil) {
    [_username release];
  }
  [to retain];
  _username = to;
}
 
-(NSString *)password
{
  return _password;
}
 
-(void)setPassword:(NSString *)to
{
  if(_password != nil) {
    [_password release];
  }
  [to retain];
  _password = to;
}
 
-(NSString *)forUser
{
  return _forUser;
}
 
-(void)setForUser:(NSString *)to
{
  if(_forUser != nil) {
    [_forUser release];
  }
  [to retain];
  _forUser = to;
}
 
-(NSString *)destDir
{
  return _destDir;
}
 
-(void)setDestDir:(NSString *)to
{
  if(_destDir != nil) {
    [_destDir release];
  }
  [to retain];
  _destDir = to;
}
 
@end