Browse Source

Raimage 1.18

iOS 16 compatible fix
Ray Zhang 3 năm trước cách đây
mục cha
commit
f63c885eea

+ 2 - 2
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -1013,7 +1013,7 @@
 				INFOPLIST_FILE = "RA Image/Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.16;
+				MARKETING_VERSION = 1.17;
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1030,7 +1030,7 @@
 				INFOPLIST_FILE = "RA Image/Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.16;
+				MARKETING_VERSION = 1.17;
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";

+ 1 - 1
RA Image/RA Image/BasicModeViewController.h

@@ -18,7 +18,7 @@
 @property (nonatomic,strong) NSMutableArray <NSMutableDictionary *> *photos;
 @property (nonatomic,copy) NSString *verify_msg0;
 
-- (void)addTasks;
+-(void)addTasks;
 
 -(void) verify:(NSMutableDictionary*) params;
 - (void)showPhotoList;

+ 4 - 1
RA Image/RA Image/BasicModeViewController.m

@@ -29,7 +29,10 @@
 @end
 
 @implementation BasicModeViewController
-
+-(void)addTasks
+{
+    //由子类实现
+}
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.

+ 3 - 1
RA Image/RA Image/RAPhotoPreviewModel/RAPhotoPreviewModel.m

@@ -13,8 +13,10 @@
 - (void)setPath:(NSString *)path {
     _path = path;
     
+    
+    
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
-        if (_path == nil) {
+        if (self.path == nil) {
             self.image = nil;
         } else {
             UIImage *img = [UIImage imageWithContentsOfFile:path];

+ 1 - 1
common/Camera/RACameraViewController.h

@@ -11,7 +11,7 @@
 #import "RACamera.h"
 
 
-@interface RACameraViewController : UIViewController
+@interface RACameraViewController : UIViewController 
 
 @property (nonatomic,copy) void (^completion)(UIImage *image);
 

+ 117 - 46
common/Camera/RACameraViewController.m

@@ -12,7 +12,7 @@
 #import <CoreMotion/CoreMotion.h>
 
 
-@interface RACameraViewController ()
+@interface RACameraViewController ()<AVCapturePhotoCaptureDelegate>
 
 @property (nonatomic,strong) IBOutlet UIView *previewContainer;
 @property (nonatomic,strong) IBOutlet UIView *controlContanier;
@@ -26,7 +26,11 @@
 @property (nonatomic,strong) AVCaptureDevice *captureDevice;
 @property (nonatomic,strong) AVCaptureSession *captureSession;
 @property (nonatomic,strong) AVCaptureDeviceInput *captureInput;
-@property (nonatomic,strong) AVCaptureStillImageOutput *captureOutput;
+//@property (nonatomic,strong) AVCaptureStillImageOutput *captureOutput;
+
+
+@property (nonatomic,strong) AVCapturePhotoSettings *photoSetting;
+@property (nonatomic,strong) AVCapturePhotoOutput* photoOutput;
 @property (nonatomic,strong) AVCaptureVideoPreviewLayer *previewLayer;
 
 @property (nonatomic,assign) BOOL cameraInitial;
@@ -297,6 +301,8 @@
 
 - (void)initCapture {
     
+    
+    self.photoSetting= [AVCapturePhotoSettings photoSettings];
     self.cameraInitial = NO;
     
     if (![self camerAuthorization]) {
@@ -339,10 +345,13 @@
         _captureSession.sessionPreset = AVCaptureSessionPresetPhoto;
     }
     
-    if ([self.captureDevice isFlashAvailable] && [_captureDevice isFlashModeSupported:AVCaptureFlashModeAuto]) {
+//    if ([self.captureDevice isFlashAvailable] && [_captureDevice isFlashModeSupported:AVCaptureFlashModeAuto]) {
+    if ([self.captureDevice isFlashAvailable] && [self.photoOutput supportedFlashModes]) {
         NSError *configErr;
         [self.captureDevice lockForConfiguration:&configErr];
-        [self.captureDevice setFlashMode:AVCaptureFlashModeAuto];
+//        AVCapturePhotoSettings.flashMode
+        self.photoSetting.flashMode =AVCaptureFlashModeAuto;
+//        [self.captureDevice setFlashMode:AVCaptureFlashModeAuto];
         [self.captureDevice unlockForConfiguration];
     }
     
@@ -384,13 +393,17 @@
     if (!self.cameraInitial) {
         return;
     }
-    self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
+//    self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
+    self.photoOutput = [AVCapturePhotoOutput new];
     
-    NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
-    [self.captureOutput setOutputSettings:setting];
-    
-    if ([self.captureSession canAddOutput:self.captureOutput]) {
-        [self.captureSession addOutput:self.captureOutput];
+//    NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
+//    AVVideoCodecTypeJPEG
+
+//    self.photoSetting.cod
+//    [self.captureOutput setOutputSettings:setting];
+//
+    if ([self.captureSession canAddOutput:self.photoOutput]) {
+        [self.captureSession addOutput:self.photoOutput];
     }
     
 //    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
@@ -402,8 +415,26 @@
 
 - (AVCaptureDevice *) videoDevicePosition:(AVCaptureDevicePosition)position {
 
-    NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
-    for (AVCaptureDevice *device in videoDevices) {
+//    NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
+    
+    
+    AVCaptureDeviceDiscoverySession * _Nonnull cameras = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera] mediaType:AVMediaTypeVideo position: AVCaptureDevicePositionUnspecified];//AVCaptureDevicePositionFront & AVCaptureDevicePositionBack
+//       //获取当前摄像头方向
+//       AVCaptureDevicePosition currentPosition = self.captureDeviceInput.device.position;
+//       AVCaptureDevicePosition toPosition = AVCaptureDevicePositionUnspecified;
+//       if (currentPosition == AVCaptureDevicePositionBack || currentPosition == AVCaptureDevicePositionUnspecified) {
+//           toPosition = AVCaptureDevicePositionFront;
+//       }else{
+//           toPosition = AVCaptureDevicePositionBack;
+//       }
+    
+    
+//    NSArray* captureDeviceArray = [cameras.devices filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"position == %d",toPosition]];
+//    if (captureDeviceArray.count == 0) {
+//        return [self throw_errorWithDomain:@"VideoCapture: reverseCamera failed! get new  camera failed!"];
+//    }
+    
+    for (AVCaptureDevice *device in cameras.devices) {
         if ([device position] == position) {
             return device;
         }
@@ -451,42 +482,45 @@
         return;
     }
     sender.enabled = false;
-    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
-
-    if (connection.isVideoOrientationSupported) { // addOutput之后判断,否则一直都是false
-        connection.videoOrientation =  [self captureVideoOrientation];
-    }
-    
+//    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
+//
+//    if (connection.isVideoOrientationSupported) { // addOutput之后判断,否则一直都是false
+//        connection.videoOrientation =  [self captureVideoOrientation];
+//    }
+//
 //    NSLog(@"capture orientation %ld",connection.videoOrientation);
     ;
-    __weak typeof(self) weakSelf = self;
-    [self.captureOutput captureStillImageAsynchronouslyFromConnection:connection completionHandler:^(CMSampleBufferRef  _Nullable imageDataSampleBuffer, NSError * _Nullable error) {
-        
-        if (imageDataSampleBuffer) {
-            NSData *imageData=[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
-            UIImage *image=[UIImage imageWithData:imageData];
-            
-            RATakePhotoPreviewController *preVC = [RATakePhotoPreviewController viewControllerFromStoryboard];
-            preVC.photoHandler = ^(UIImage *img){
-                if (weakSelf) {
-                    __strong typeof(weakSelf) strongSelf = weakSelf;
-                    if (strongSelf.completion) {
-                        strongSelf.completion(img);
-                    }
-                }
-            };
-            preVC.preImage = image;
-            if (weakSelf.takeMode == RACameraTakeModeTakeOnce) {
-                preVC.popTo = weakSelf.fromVC;
-                preVC.barHidden = weakSelf.barHidden;
-            }
-            [weakSelf.navigationController pushViewController:preVC animated:YES];
-            
-        } else {
-            NSLog(@"take picture failed: %@",error);
-        }
-        sender.enabled = true;
-    }];
+//    __weak typeof(self) weakSelf = self;
+    
+    [self.photoOutput capturePhotoWithSettings:self.photoSetting delegate:self];
+//
+//    [self.captureOutput captureStillImageAsynchronouslyFromConnection:connection completionHandler:^(CMSampleBufferRef  _Nullable imageDataSampleBuffer, NSError * _Nullable error) {
+//
+//        if (imageDataSampleBuffer) {
+//            NSData *imageData=[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
+//            UIImage *image=[UIImage imageWithData:imageData];
+//
+//            RATakePhotoPreviewController *preVC = [RATakePhotoPreviewController viewControllerFromStoryboard];
+//            preVC.photoHandler = ^(UIImage *img){
+//                if (weakSelf) {
+//                    __strong typeof(weakSelf) strongSelf = weakSelf;
+//                    if (strongSelf.completion) {
+//                        strongSelf.completion(img);
+//                    }
+//                }
+//            };
+//            preVC.preImage = image;
+//            if (weakSelf.takeMode == RACameraTakeModeTakeOnce) {
+//                preVC.popTo = weakSelf.fromVC;
+//                preVC.barHidden = weakSelf.barHidden;
+//            }
+//            [weakSelf.navigationController pushViewController:preVC animated:YES];
+//
+//        } else {
+//            NSLog(@"take picture failed: %@",error);
+//        }
+//        sender.enabled = true;
+//    }];
 }
 
 - (IBAction)returnButtonClick:(UIButton *)sender {
@@ -518,4 +552,41 @@
     return img;
 }
 
+
+#pragma mark - AVCapturePhotoCaptureDelegate
+-(void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto:(AVCapturePhoto *)photo error:(NSError *)error  API_AVAILABLE(ios(11.0)) {
+    if (!error) {
+        // 使用该方式获取图片,可能图片会存在旋转问题,在使用的时候调整图片即可
+        NSData *imageData = [photo fileDataRepresentation];
+        UIImage *image = [UIImage imageWithData:imageData];
+
+        
+//              NSData *imageData=[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
+//              UIImage *image=[UIImage imageWithData:imageData];
+  
+              RATakePhotoPreviewController *preVC = [RATakePhotoPreviewController viewControllerFromStoryboard];
+              preVC.photoHandler = ^(UIImage *img){
+
+                  if (self.completion) {
+                      self.completion(img);
+                  }
+              };
+              preVC.preImage = image;
+              if (self.takeMode == RACameraTakeModeTakeOnce) {
+                  preVC.popTo = self.fromVC;
+                  preVC.barHidden = self.barHidden;
+              }
+              [self.navigationController pushViewController:preVC animated:YES];
+  
+          } else {
+              NSLog(@"take picture failed: %@",error);
+          }
+//          sender.enabled = true;
+    self.takePhotoBtn.enabled = true;
+        
+        
+    
+}
+
+
 @end

+ 209 - 208
common/NetworkUtils.m

@@ -41,216 +41,217 @@
 
 +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString*)file_path err_recorder:(NSString* )recorder_url result_handler:(resultBlock)resultBlock decrypt_handler:(decryptBlock)decryptBlock
 {
-    int retry = 0;
+//    int retry = 0;
     
 
-    
-    
-repeat:
-    {
-        
-        //    return [self fake_json:url];
-        
-        //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-        //分界线的标识符
-        NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
-        //根据url初始化request
-        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
-                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
-                                                           timeoutInterval:JSON_TIMEOUT];
-
-        //分界线 --AaB03x
-        NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
-        //结束符 AaB03x--
-        NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
-        //要上传的图片
-        //    UIImage *image=[params objectForKey:@"pic"];
-        //得到图片的data
-            NSData* data = [NSData dataWithContentsOfFile:file_path];
-        //http body的字符串
-        NSMutableString *body=[[NSMutableString alloc]init];
-        
-        //    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
-        //     [params setValue:@"handset_login" forKey:@"action"];
-        //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
-        
-        //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
-        //   [params setValue:password forKey:@"password"];
-        //    [params setValue:[NSString stringWithFormat:@"%d",ver]  forKey:@"auth_ver"];
-        
-        
-        
-        //    [headers setValue:headQuerlString forKey:@"param"];
-        
-        //参数的集合的所有key的集合
-        NSArray *keys= [params allKeys];
-        DebugLog(@"================parms==================");
-        //遍历keys
-        for(int i=0;i<[keys count];i++)
-        {
-            //得到当前key
-            NSString *key=[keys objectAtIndex:i];
-            //如果key不是pic,说明value是字符类型,比如name:Boris
-            if(![key isEqualToString:@"pic"])
-            {
-                //添加分界线,换行
-                [body appendFormat:@"%@\r\n",MPboundary];
-                //添加字段名称,换2行
-                [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
-                //添加字段的值
-                [body appendFormat:@"%@\r\n",[params objectForKey:key]];
-                DebugLog(@"parameter: key=%@   value=%@",key,[params objectForKey:key]);
-            }
-        }
-        DebugLog(@"================parms==================");
-        ////添加分界线,换行
-        [body appendFormat:@"%@\r\n",MPboundary];
-        //声明pic字段,文件名为boris.png
-        
-        NSString * file_format=[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upfile\"; filename=\"%@\"\r\n", [file_path lastPathComponent]];
-
-        
-        
-        [body appendFormat:@"%@", file_format];
-        //声明上传文件的格式
-        [body appendFormat:@"Content-Type: application/zip\r\n\r\n"];
-        
-        //声明结束符:--AaB03x--
-        NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
-        //声明myRequestData,用来放入http body
-        NSMutableData *myRequestData=[NSMutableData data];
-        //将body字符串转化为UTF8格式的二进制
-        [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
-        //将image的data加入
-            [myRequestData appendData:data];
-        //加入结束符--AaB03x--
-        [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
-        
-        //设置HTTPHeader中Content-Type的值
-        NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
-        //设置HTTPHeader
-        [request setValue:content forHTTPHeaderField:@"Content-Type"];
-        
-        [request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"];
-        
-        // 关闭keep alive
-        [request setValue:@"close" forHTTPHeaderField:@"Connection"];
-        //设置Content-Length
-        [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
-        //设置http body
-        [request setHTTPBody:myRequestData];
-        //http method
-        [request setHTTPMethod:@"POST"];
-        
-        NSLog(@"%@", [[NSString alloc] initWithData:myRequestData encoding:NSUTF8StringEncoding]);
-        NSHTTPURLResponse* urlResponse = nil;
-        
-        NSError *error = nil;
-        NSLog(@"begin request %@",url);
-
-        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
-        
-        
-        DebugLog(@"url: %@",url);
-        
-        DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
-        
-        
-        NSLog(@"get response");
-        if (responseData==nil) {
-            
-            //            DebugLog(@"response error:%@", [error localizedDescription]);
-            
-            
-            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
-            //#define RESULT_FALSE 0
-            //#define RESULT_TRUE		 2
-            //#define RESULT_NET_ERROR			 -3
-            //#define RESULT_NET_NOTAVAILABLE		  -4
-            //#define RESULT_ERROR				 -5
-            //#define RESULT_LOCALFILE_ERROR			 -7
-            //#define RESULT_USERAUTH_ERROR			 -9
-            //#define RESULT_UPDATE_USERAUTH_ERROR	 -11
-            //#define RESULT_SESSION_EXPIRED			  -13
-            //#define RESULT_VER_LOW
-            
-            //     NSString * moreinfo = error.description ;
-            
-            NSString* err_msg = [error localizedDescription];
-            
-            
-            //-----------------retry 3 times for error code -1005------------------------
-            if(error.code==-1005&&retry<3)
-            {
-                retry++;
-                goto repeat;
-                
-            }
-            //-----------------end retry 3 times for error code -1005------------------------
-            
-            NSDictionary* error_json = [RAUtils error_dict:error];
-            [ret setObject:error_json forKey:@"err_obj"];
-            NSString* resp_msg= nil;
-            
-            if(err_msg.length==0)
-            {
-                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
-                resp_msg = err_msg;
-            }
-            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
-            [ret setValue:err_msg forKey:@"err_msg"];
-            [ret setValue:resp_msg forKey:@"resp_msg"];
-            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
-            
-            
-            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
-                                                               options:0
-                                                                 error:nil];
-            if(![url isEqualToString:recorder_url])
-            {
-                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
-            }
-            return jsonData;
-            
-        }
-        else
-        {
-          //  NSString* err_msg = [error localizedDescription];
-            NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
-            
-            DebugLog(@"data string: %@",str);
-            NSError *error1 = nil;
-            
-            NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
-            
-            if(jsobj==nil)// 服务器返回不是json
-            {
-                
-                jsobj=[[NSMutableDictionary alloc] init];
-                [jsobj setValue:[NSNumber numberWithInt:RESULT_NO_RESPONSE] forKey:@"result"];
-                
-            }
-            if([jsobj[@"encrypt"] boolValue]==true)
-            {
-                jsobj = decryptBlock(jsobj);
-            }
-            if (resultBlock) {
-                jsobj = resultBlock(jsobj);
-            }
-            
-            int result=[[jsobj valueForKey:@"result"] intValue];
-            if(![url isEqualToString:recorder_url]&&/*![url isEqualToString:URL_DOWNLOAD_OFFLINE]&&*/result!=2&&result!=99)
-            {
-                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
-            }
-            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
-                                                               options:0
-                                                                 error:nil];
-            return jsonData;
-            
-        }
-        return responseData;
-    }
+    NSAssert(false, @"The get_json is obsolete, use the request_interface instead");
+    return nil;
+//    
+//repeat:
+//    {
+//        
+//        //    return [self fake_json:url];
+//        
+//        //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//        //分界线的标识符
+//        NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
+//        //根据url初始化request
+//        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
+//                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+//                                                           timeoutInterval:JSON_TIMEOUT];
+//
+//        //分界线 --AaB03x
+//        NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
+//        //结束符 AaB03x--
+//        NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
+//        //要上传的图片
+//        //    UIImage *image=[params objectForKey:@"pic"];
+//        //得到图片的data
+//            NSData* data = [NSData dataWithContentsOfFile:file_path];
+//        //http body的字符串
+//        NSMutableString *body=[[NSMutableString alloc]init];
+//        
+//        //    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+//        //     [params setValue:@"handset_login" forKey:@"action"];
+//        //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
+//        
+//        //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
+//        //   [params setValue:password forKey:@"password"];
+//        //    [params setValue:[NSString stringWithFormat:@"%d",ver]  forKey:@"auth_ver"];
+//        
+//        
+//        
+//        //    [headers setValue:headQuerlString forKey:@"param"];
+//        
+//        //参数的集合的所有key的集合
+//        NSArray *keys= [params allKeys];
+//        DebugLog(@"================parms==================");
+//        //遍历keys
+//        for(int i=0;i<[keys count];i++)
+//        {
+//            //得到当前key
+//            NSString *key=[keys objectAtIndex:i];
+//            //如果key不是pic,说明value是字符类型,比如name:Boris
+//            if(![key isEqualToString:@"pic"])
+//            {
+//                //添加分界线,换行
+//                [body appendFormat:@"%@\r\n",MPboundary];
+//                //添加字段名称,换2行
+//                [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
+//                //添加字段的值
+//                [body appendFormat:@"%@\r\n",[params objectForKey:key]];
+//                DebugLog(@"parameter: key=%@   value=%@",key,[params objectForKey:key]);
+//            }
+//        }
+//        DebugLog(@"================parms==================");
+//        ////添加分界线,换行
+//        [body appendFormat:@"%@\r\n",MPboundary];
+//        //声明pic字段,文件名为boris.png
+//        
+//        NSString * file_format=[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upfile\"; filename=\"%@\"\r\n", [file_path lastPathComponent]];
+//
+//        
+//        
+//        [body appendFormat:@"%@", file_format];
+//        //声明上传文件的格式
+//        [body appendFormat:@"Content-Type: application/zip\r\n\r\n"];
+//        
+//        //声明结束符:--AaB03x--
+//        NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
+//        //声明myRequestData,用来放入http body
+//        NSMutableData *myRequestData=[NSMutableData data];
+//        //将body字符串转化为UTF8格式的二进制
+//        [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
+//        //将image的data加入
+//            [myRequestData appendData:data];
+//        //加入结束符--AaB03x--
+//        [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
+//        
+//        //设置HTTPHeader中Content-Type的值
+//        NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
+//        //设置HTTPHeader
+//        [request setValue:content forHTTPHeaderField:@"Content-Type"];
+//        
+//        [request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"];
+//        
+//        // 关闭keep alive
+//        [request setValue:@"close" forHTTPHeaderField:@"Connection"];
+//        //设置Content-Length
+//        [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
+//        //设置http body
+//        [request setHTTPBody:myRequestData];
+//        //http method
+//        [request setHTTPMethod:@"POST"];
+//        
+//        NSLog(@"%@", [[NSString alloc] initWithData:myRequestData encoding:NSUTF8StringEncoding]);
+//        NSHTTPURLResponse* urlResponse = nil;
+//        
+//        NSError *error = nil;
+//        NSLog(@"begin request %@",url);
+//
+//        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
+//        
+//        
+//        DebugLog(@"url: %@",url);
+//        
+//        DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
+//        
+//        
+//        NSLog(@"get response");
+//        if (responseData==nil) {
+//            
+//            //            DebugLog(@"response error:%@", [error localizedDescription]);
+//            
+//            
+//            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+//            //#define RESULT_FALSE 0
+//            //#define RESULT_TRUE		 2
+//            //#define RESULT_NET_ERROR			 -3
+//            //#define RESULT_NET_NOTAVAILABLE		  -4
+//            //#define RESULT_ERROR				 -5
+//            //#define RESULT_LOCALFILE_ERROR			 -7
+//            //#define RESULT_USERAUTH_ERROR			 -9
+//            //#define RESULT_UPDATE_USERAUTH_ERROR	 -11
+//            //#define RESULT_SESSION_EXPIRED			  -13
+//            //#define RESULT_VER_LOW
+//            
+//            //     NSString * moreinfo = error.description ;
+//            
+//            NSString* err_msg = [error localizedDescription];
+//            
+//            
+//            //-----------------retry 3 times for error code -1005------------------------
+//            if(error.code==-1005&&retry<3)
+//            {
+//                retry++;
+//                goto repeat;
+//                
+//            }
+//            //-----------------end retry 3 times for error code -1005------------------------
+//            
+//            NSDictionary* error_json = [RAUtils error_dict:error];
+//            [ret setObject:error_json forKey:@"err_obj"];
+//            NSString* resp_msg= nil;
+//            
+//            if(err_msg.length==0)
+//            {
+//                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
+//                resp_msg = err_msg;
+//            }
+//            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
+//            [ret setValue:err_msg forKey:@"err_msg"];
+//            [ret setValue:resp_msg forKey:@"resp_msg"];
+//            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
+//            
+//            
+//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
+//                                                               options:0
+//                                                                 error:nil];
+//            if(![url isEqualToString:recorder_url])
+//            {
+//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
+//            }
+//            return jsonData;
+//            
+//        }
+//        else
+//        {
+//          //  NSString* err_msg = [error localizedDescription];
+//            NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
+//            
+//            DebugLog(@"data string: %@",str);
+//            NSError *error1 = nil;
+//            
+//            NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
+//            
+//            if(jsobj==nil)// 服务器返回不是json
+//            {
+//                
+//                jsobj=[[NSMutableDictionary alloc] init];
+//                [jsobj setValue:[NSNumber numberWithInt:RESULT_NO_RESPONSE] forKey:@"result"];
+//                
+//            }
+//            if([jsobj[@"encrypt"] boolValue]==true)
+//            {
+//                jsobj = decryptBlock(jsobj);
+//            }
+//            if (resultBlock) {
+//                jsobj = resultBlock(jsobj);
+//            }
+//            
+//            int result=[[jsobj valueForKey:@"result"] intValue];
+//            if(![url isEqualToString:recorder_url]&&/*![url isEqualToString:URL_DOWNLOAD_OFFLINE]&&*/result!=2&&result!=99)
+//            {
+//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
+//            }
+//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
+//                                                               options:0
+//                                                                 error:nil];
+//            return jsonData;
+//            
+//        }
+//        return responseData;
+//    }
 }
 
 +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code//device:(NSString*) device

+ 4 - 0
common/UIImage+fixOrientation.m

@@ -36,6 +36,8 @@
             transform = CGAffineTransformTranslate(transform, 0, self.size.height);
             transform = CGAffineTransformRotate(transform, -M_PI_2);
             break;
+        default:
+            break;
     }
     
     switch (self.imageOrientation) {
@@ -50,6 +52,8 @@
             transform = CGAffineTransformTranslate(transform, self.size.height, 0);
             transform = CGAffineTransformScale(transform, -1, 1);
             break;
+        default:
+            break;
     }
     
     // Now we draw the underlying CGImage into a new context, applying the transform