Skip to content

Commit

Permalink
Update for reinstall & CustomLog
Browse files Browse the repository at this point in the history
  • Loading branch information
ding_yuanyi authored and ding_yuanyi committed Nov 28, 2012
1 parent fedde9d commit fc10ae5
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LatestBuild
8 changes: 8 additions & 0 deletions NCProxySwitcher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
DF2A0B1716633B280010109F /* PacViewer.h in Headers */ = {isa = PBXBuildFile; fileRef = DF2A0B1516633B280010109F /* PacViewer.h */; };
DF2A0B1816633B280010109F /* PacViewer.m in Sources */ = {isa = PBXBuildFile; fileRef = DF2A0B1616633B280010109F /* PacViewer.m */; };
DF367D791665BC180000907C /* CustomLog.h in Headers */ = {isa = PBXBuildFile; fileRef = DF367D771665BC180000907C /* CustomLog.h */; };
DF367D7A1665BC180000907C /* CustomLog.m in Sources */ = {isa = PBXBuildFile; fileRef = DF367D781665BC180000907C /* CustomLog.m */; };
DFF21F51165F423100E1C91B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF21F50165F423100E1C91B /* Foundation.framework */; };
DFF21F53165F423100E1C91B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFF21F52165F423100E1C91B /* UIKit.framework */; };
DFF21F5E165F423100E1C91B /* NCProxySwitcherController.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF21F5D165F423100E1C91B /* NCProxySwitcherController.m */; };
Expand All @@ -17,6 +19,8 @@
/* Begin PBXFileReference section */
DF2A0B1516633B280010109F /* PacViewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacViewer.h; sourceTree = "<group>"; };
DF2A0B1616633B280010109F /* PacViewer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PacViewer.m; sourceTree = "<group>"; };
DF367D771665BC180000907C /* CustomLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomLog.h; sourceTree = "<group>"; };
DF367D781665BC180000907C /* CustomLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomLog.m; sourceTree = "<group>"; };
DFF21F4D165F423100E1C91B /* NCProxySwitcher */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = NCProxySwitcher; sourceTree = BUILT_PRODUCTS_DIR; };
DFF21F50165F423100E1C91B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
DFF21F52165F423100E1C91B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -75,6 +79,8 @@
DFF21F54165F423100E1C91B /* NCProxySwitcher */ = {
isa = PBXGroup;
children = (
DF367D771665BC180000907C /* CustomLog.h */,
DF367D781665BC180000907C /* CustomLog.m */,
DF2A0B1516633B280010109F /* PacViewer.h */,
DF2A0B1616633B280010109F /* PacViewer.m */,
DFF21F5C165F423100E1C91B /* NCProxySwitcherController.h */,
Expand Down Expand Up @@ -156,6 +162,7 @@
buildActionMask = 2147483647;
files = (
DF2A0B1716633B280010109F /* PacViewer.h in Headers */,
DF367D791665BC180000907C /* CustomLog.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -228,6 +235,7 @@
files = (
DFF21F5E165F423100E1C91B /* NCProxySwitcherController.m in Sources */,
DF2A0B1816633B280010109F /* PacViewer.m in Sources */,
DF367D7A1665BC180000907C /* CustomLog.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
11 changes: 11 additions & 0 deletions NCProxySwitcher/CustomLog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// CustomLog.h
// NCProxySwitcher
//
// Created by ding_yuanyi on 12-11-28.
//
//

#define NSLog(...) CustomLogger(__VA_ARGS__);

void CustomLogger(NSString *format, ...);
20 changes: 20 additions & 0 deletions NCProxySwitcher/CustomLog.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// CustomLog.m
// NCProxySwitcher
//
// Created by ding_yuanyi on 12-11-28.
//
//

void CustomLogger(NSString *format, ...) {
va_list argumentList;
va_start(argumentList, format);
NSMutableString * message = [[NSMutableString alloc] initWithFormat:format
arguments:argumentList];

[message insertString:@"||--NCProxySwitcher--|| : " atIndex:0];
NSLogv(message, argumentList);

va_end(argumentList);
[message release];
}
2 changes: 2 additions & 0 deletions NCProxySwitcher/NCProxySwitcher-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import "CustomLog.h"
#endif

41 changes: 40 additions & 1 deletion NCProxySwitcher/NCProxySwitcherController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
#define kProxyAutoPacPath @"/var/mobile/PAC/Proxy_ignoreLocal.pac"
#define kProxyAllPacPath @"/var/mobile/PAC/Proxy_all.pac"

#define kMobilePacDir @"/var/mobile/PAC/"
#define kDocumentsPacDir @"/var/mobile/Documents/OriginalPACs/"

@implementation NCProxySwitcherController
@synthesize pacArray;

- (id)init
{
[self copyOriginalPacsToMobilePacDirIfNeeded];

if ((self = [super init]))
{
self.pacArray = [NSArray arrayWithObjects:kDirectPacPath, kProxyAutoPacPath, kProxyAllPacPath, nil];
Expand All @@ -33,6 +38,40 @@ - (id)init
return self;
}

- (void)copyOriginalPacsToMobilePacDirIfNeeded
{
NSFileManager *fm = [NSFileManager defaultManager];

NSError *creatDirError = nil;
if (![fm createDirectoryAtPath:kMobilePacDir withIntermediateDirectories:NO attributes:nil error:&creatDirError])
{
NSLog(@"Creat Mobile PAC Dir Error: %@", creatDirError);
}
else
{
NSLog(@"Created Mobile PAC Dir Successfully");
}

for (NSString *path in [fm subpathsAtPath:kDocumentsPacDir])
{
if (![fm fileExistsAtPath:[kMobilePacDir stringByAppendingString:path]])
{
NSError *error = nil;
NSString *pacStr = [NSString stringWithContentsOfFile:[kDocumentsPacDir stringByAppendingString:path] encoding:NSUTF8StringEncoding error:&error];
NSError *writeError = nil;
[pacStr writeToFile:[kMobilePacDir stringByAppendingString:path] atomically:NO encoding:NSUTF8StringEncoding error:&writeError];
if (writeError)
{
NSLog(@"Write Error: %@", writeError);
}
}
else
{
NSLog(@"%@ Exists", [kMobilePacDir stringByAppendingString:path]);
}
}
}

- (void)dealloc
{
NSLog(@"Dealloc==============");
Expand Down Expand Up @@ -314,7 +353,7 @@ - (void)longPress:(UILongPressGestureRecognizer *)gesture
UITableView *NCTableView = (UITableView *)_view.superview.superview.superview;

NSLog(@"NCTableView Delegate : %@", NCTableView.delegate);
NSLog(@"NCTableView.superview : %@", _view.superview.superview.superview.superview);
NSLog(@"NCView : %@", _view.superview.superview.superview.superview);
NSLog(@"NCTableView.superview.superview : %@", _view.superview.superview.superview.superview.superview);
NSLog(@"rootWindow : %@", _view.superview.superview.superview.superview.superview.superview);

Expand Down
Binary file not shown.
Binary file modified Packages/com.hoperun.NCProxySwitcher_1.0-1_iphoneos-arm.deb
Binary file not shown.
Binary file modified Packages/com.hoperun.NCProxySwitcher_1.0-1_iphoneos-arm.zip
Binary file not shown.

0 comments on commit fc10ae5

Please sign in to comment.