Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from oskarirauta/master
Browse files Browse the repository at this point in the history
some more ui re-newing..
  • Loading branch information
thepatrick committed Feb 7, 2012
2 parents 8c8cb0b + 2ab2573 commit 22ee99d
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 35 deletions.
8 changes: 7 additions & 1 deletion Classes/CWConnectionStateValueTransformer.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ - (id)transformedValue:(id)value
{
CWModel *model = (CWModel *)value;
CWDurationValueTransformer *valueTransformer;


/*
if ([model ongoingPIN]) {
return NSLocalizedString(@"L286", @"");
}
*/

switch ([model connectionState]) {
// for possible values see table 4-3 in
// http://developer.apple.com/mac/library/documentation/Networking/Conceptual/SystemConfigFrameworks/SC_ReachConnect/SC_ReachConnect.html
Expand Down
29 changes: 15 additions & 14 deletions Classes/CWIconValueTransformer.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ - (id)transformedValue:(id)value
NSDictionary *stringAttributes;
NSAttributedString *modeString;
NSString *modeRawString;
NSColor *color;
NSString *iconName;
NSImage *rawIcon, *rawIcon2;

Expand All @@ -125,18 +124,15 @@ - (id)transformedValue:(id)value
iconName = @"signal-4";
}
// construct mode and duration string
color = connected ? [NSColor colorWithCalibratedRed:0.05 green:0.37 blue:0.80 alpha:1] :
[NSColor colorWithCalibratedRed:0.40 green:0.40 blue:0.40 alpha:1];
stringAttributes = [NSDictionary dictionaryWithObjectsAndKeys:menuFont, NSFontAttributeName, color, NSForegroundColorAttributeName, nil];
// show mode and connection state or only mode, depending on connection state and preference setting
stringAttributes = [NSDictionary dictionaryWithObjectsAndKeys:menuFont, NSFontAttributeName, [NSColor colorWithCalibratedRed:0.32 green:0.32 blue:0.32 alpha:1], NSForegroundColorAttributeName, nil];
// show mode and connection state or only mode, depending on connection state and preference setting & create status icon
if (connected && [[model preferences] showConnectionTime]) {
modeRawString = [NSString stringWithFormat:@"%@", CWPrettyTime([model duration])];
modeString = [[NSAttributedString alloc] initWithString:modeRawString attributes:stringAttributes];
statusIcon = [[[NSImage alloc] initWithSize:NSMakeSize(41 + [modeString size].width, 22)] autorelease];
} else {
modeRawString = @"";
statusIcon = [[[NSImage alloc] initWithSize:NSMakeSize(41, 22)] autorelease];
}
modeString = [[NSAttributedString alloc] initWithString:modeRawString attributes:stringAttributes];
// create status icon
statusIcon = [[[NSImage alloc] initWithSize:NSMakeSize(41 + [modeString size].width, 22)] autorelease];
// load raw icon with bars - append -off suffix if not connected
rawIcon = [NSImage imageNamed:[iconName stringByAppendingString:connected ? @"" : @"-off"]];
// draw raw icon into status icon
Expand All @@ -145,13 +141,18 @@ - (id)transformedValue:(id)value
// load second raw icon which shows connection state
if ( connected ) {
rawIcon2 = [NSImage imageNamed: [self modeIndicatorIconname:[model mode]]];
[rawIcon2 drawAtPoint:NSMakePoint(22, 0) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
if ([[model preferences] showConnectionTime]) {
// show connection time
[modeString drawAtPoint:NSMakePoint(41, 3)];
[modeString release];
}
} else {
rawIcon2 = [NSImage imageNamed: @"lock-off"];
if ([model carrier] == NULL) {
rawIcon2 = [NSImage imageNamed: @"lock-off"];
[rawIcon2 drawAtPoint:NSMakePoint(22, 0) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
}
}
[rawIcon2 drawAtPoint:NSMakePoint(22, 0) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
// draw mode indicator
[modeString drawAtPoint:NSMakePoint(41, 3)];
[modeString release];
// unlock drawing focus again
[statusIcon unlockFocus];
return statusIcon;
Expand Down
4 changes: 4 additions & 0 deletions Classes/CWModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef enum {
CWModesPreference modesPreference;
BOOL pinLock;
BOOL alwaysDisabled;
BOOL ongoingPIN;

CWConnectionRecord *currentRecord;

Expand Down Expand Up @@ -163,6 +164,9 @@ typedef enum {

//- (BOOL)alwaysDisabled;

- (BOOL)ongoingPIN;
- (void)setOngoingPIN:(BOOL)PINstatus;

- (void)checkTrafficLimit;

- (id)delegate;
Expand Down
9 changes: 9 additions & 0 deletions Classes/CWModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ - (void)reset
[self setModel:nil];
[self setModesPreference:0];
[self setPinLock:NO];
[self setOngoingPIN:NO];
}

// write model to disk
Expand Down Expand Up @@ -581,6 +582,14 @@ - (void)setPinLock:(BOOL)status
pinLock = status;
}

- (BOOL)ongoingPIN
{return ongoingPIN;}
- (void)setOngoingPIN:(BOOL)PINstatus
{
ongoingPIN = PINstatus;
}


- (void)checkTrafficLimit
{
if ([preferences trafficWarning]) {
Expand Down
1 change: 0 additions & 1 deletion Classes/CWModem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
NSMutableArray *modemCommands;
NSTimer *periodicTimer;
NSTimer *commandTimeoutTimer;
BOOL ongoingPIN;

// delegate
id delegate;
Expand Down
30 changes: 15 additions & 15 deletions Classes/CWModem.m
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,19 @@ - (void)processCPIN:(NSScanner *)scanner

if ([pinState isEqual:@"READY"]) {
return;
} else if (([pinState isEqual:@"SIM PIN"]) && (!ongoingPIN)) {
} else if (([pinState isEqual:@"SIM PIN"]) && (![model ongoingPIN])) {
if (delegate && [delegate respondsToSelector:@selector(needsPin:)]) {
ongoingPIN = true;
[model setOngoingPIN:YES];
[delegate needsPin:pinState];
}
} else if (([pinState isEqual:@"SIM PUK"]) && (!ongoingPIN)) {
} else if (([pinState isEqual:@"SIM PUK"]) && (![model ongoingPIN])) {
if (delegate && [delegate respondsToSelector:@selector(needsPuk)]) {
ongoingPIN = true;
[model setOngoingPIN:YES];
[delegate needsPuk];
}
} else {
if ((delegate && [delegate respondsToSelector:@selector(needsPin:)]) && (!ongoingPIN)) {
ongoingPIN = true;
if ((delegate && [delegate respondsToSelector:@selector(needsPin:)]) && (![model ongoingPIN])) {
[model setOngoingPIN:YES];
[delegate needsPin:pinState];
}
}
Expand Down Expand Up @@ -411,8 +411,8 @@ - (void)dequeueNextModemCommand
// start timout timer
commandTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:CWCommandTimeout target:self selector:@selector(commandTimeout:)
userInfo:nil repeats:NO];
if (([command isEqual:@"AT+CPIN?\r"]) && (ongoingPIN)) {
ongoingPIN = false; // PIN status query is done after sending PIN/PUK
if (([command isEqual:@"AT+CPIN?\r"]) && ([model ongoingPIN])) {
[model setOngoingPIN:NO]; // PIN status query is done after sending PIN/PUK
}
}
}
Expand All @@ -433,19 +433,19 @@ - (void)processCMEERROR:(NSScanner *)scanner
// SIM busy, sleep 1 second, then reissue command
sleep(1);
[self dequeueNextModemCommand];
} else if (([error isEqual:@"SIM PIN required"]) && (!ongoingPIN)) {
} else if (([error isEqual:@"SIM PIN required"]) && (![model ongoingPIN])) {
if (delegate && [delegate respondsToSelector:@selector(needsPin:)]) {
ongoingPIN = true;
[model setOngoingPIN:YES];
[delegate needsPin:error];
}
} else if (([error isEqual:@"SIM PUK required"]) && (!ongoingPIN)) {
} else if (([error isEqual:@"SIM PUK required"]) && (![model ongoingPIN])) {
if (delegate && [delegate respondsToSelector:@selector(needsPuk)]) {
ongoingPIN = true;
[model setOngoingPIN:YES];
[delegate needsPuk];
}
} else if (([error isEqual:@"incorrect password"]) && (!ongoingPIN)) { // Incorrect PIN code
} else if (([error isEqual:@"incorrect password"]) && (![model ongoingPIN])) { // Incorrect PIN code
if (delegate && [delegate respondsToSelector:@selector(needsPin:)]) {
ongoingPIN = true;
[model setOngoingPIN:YES];
[delegate needsPin:error];
}
}
Expand Down Expand Up @@ -659,7 +659,7 @@ - (void)openModem:(NSString *)devicePath
[modemHandle waitForDataInBackgroundAndNotify];

// Initialization queries pin status which sets this to false
ongoingPIN = true;
[model setOngoingPIN:YES];

// send commands to query some basic information
[self sendModemCommand:@"AT+CGMI"]; // query manufacterer
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>PQG0</string>
<key>CFBundleVersion</key>
<string>70</string>
<string>90</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSUIElement</key>
Expand Down
Binary file added MenusSignals/airplane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/gprs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/gsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/lock-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-0-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-1-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-2-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-3-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-4-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/signal-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MenusSignals/umts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Resources/English.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"L283" = "Authenticating";
"L284" = "Connected (%@)";
"L285" = "Disconnecting";
"L286" = "Validating PIN";
"L299" = "Unknown";

/* time formatter with days and without days - args come in order [days:]hours:minutes:seconds - used by CWDurationValueTransformer */
Expand Down
6 changes: 3 additions & 3 deletions Resources/networks.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12311,14 +12311,14 @@
<key>operator</key>
<string>Telecommunications for Disaster Relief (TDR) (OCHA)</string>
</dict>
<key>Company40002</key>
<key>40002</key>
<dict>
<key>country</key>
<string>Azerbaijan</string>
<key>mcc</key>
<string>Company</string>
<string>400</string>
<key>mnc</key>
<string>40002</string>
<string>02</string>
<key>operator</key>
<string>Bakcell Limited Liabil ity</string>
</dict>
Expand Down

0 comments on commit 22ee99d

Please sign in to comment.