├── .gitignore ├── ChoosePeopleViewController.h ├── ChoosePeopleViewController.m ├── Classes ├── AppDelegate.h ├── AppDelegate.mm ├── DDHTextView.h ├── DDHTextView.m ├── Database.h ├── Database.m ├── FFTBufferManager.cpp ├── FFTBufferManager.h ├── FMDB │ ├── FMDatabase.h │ ├── FMDatabase.m │ ├── FMDatabaseAdditions.h │ ├── FMDatabaseAdditions.m │ ├── FMDatabasePool.h │ ├── FMDatabasePool.m │ ├── FMDatabaseQueue.h │ ├── FMDatabaseQueue.m │ ├── FMResultSet.h │ ├── FMResultSet.m │ └── fmdb.m ├── MBProgressHUD │ ├── MBProgressHUD.h │ └── MBProgressHUD.m ├── MainViewController.h ├── MainViewController.mm ├── PlayPCM │ ├── PCMRender.h │ ├── PCMRender.m │ ├── ViewController.h │ └── ViewController.m ├── RootViewController.h ├── RootViewController.mm ├── TextEditorViewController.h ├── TextEditorViewController.m ├── TextViewController.h ├── TextViewController.m ├── VdiskError__.h ├── VdiskError__.mm ├── VdiskSDK │ ├── VdiskSDK.xcodeproj │ │ └── project.pbxproj │ └── VdiskSDK │ │ ├── ASIHttpRequest │ │ ├── ASIAuthenticationDialog.h │ │ ├── ASIAuthenticationDialog.m │ │ ├── ASICacheDelegate.h │ │ ├── ASIDataCompressor.h │ │ ├── ASIDataCompressor.m │ │ ├── ASIDataDecompressor.h │ │ ├── ASIDataDecompressor.m │ │ ├── ASIDownloadCache.h │ │ ├── ASIDownloadCache.m │ │ ├── ASIFormDataRequest.h │ │ ├── ASIFormDataRequest.m │ │ ├── ASIHTTPRequest.h │ │ ├── ASIHTTPRequest.m │ │ ├── ASIHTTPRequestConfig.h │ │ ├── ASIHTTPRequestDelegate.h │ │ ├── ASIInputStream.h │ │ ├── ASIInputStream.m │ │ ├── ASINetworkQueue.h │ │ ├── ASINetworkQueue.m │ │ ├── ASIProgressDelegate.h │ │ ├── Reachability.h │ │ └── Reachability.m │ │ ├── JSON │ │ ├── NSObject+VdiskJSON.h │ │ ├── NSObject+VdiskJSON.m │ │ ├── NSString+VdiskJSON.h │ │ ├── NSString+VdiskJSON.m │ │ ├── VdiskJSON.h │ │ ├── VdiskJSON.m │ │ ├── VdiskJsonBase.h │ │ ├── VdiskJsonBase.m │ │ ├── VdiskJsonParser.h │ │ ├── VdiskJsonParser.m │ │ ├── VdiskJsonWriter.h │ │ └── VdiskJsonWriter.m │ │ ├── Logs │ │ ├── DDASLLogger.h │ │ ├── DDASLLogger.m │ │ ├── DDAbstractDatabaseLogger.h │ │ ├── DDAbstractDatabaseLogger.m │ │ ├── DDFileLogger.h │ │ ├── DDFileLogger.m │ │ ├── DDLog.h │ │ ├── DDLog.m │ │ ├── DDTTYLogger.h │ │ ├── DDTTYLogger.m │ │ └── Extensions │ │ │ ├── CLog.h │ │ │ ├── CLog.m │ │ │ ├── CLogReport.h │ │ │ ├── CLogReport.m │ │ │ ├── CompressingLogFileManager.h │ │ │ ├── CompressingLogFileManager.m │ │ │ ├── ContextFilterLogFormatter.h │ │ │ ├── ContextFilterLogFormatter.m │ │ │ ├── DispatchQueueLogFormatter.h │ │ │ ├── DispatchQueueLogFormatter.m │ │ │ ├── VdiskLogDebugFormatter.h │ │ │ ├── VdiskLogDebugFormatter.m │ │ │ ├── VdiskLogFormatter.h │ │ │ └── VdiskLogFormatter.m │ │ ├── UIDevice-Hardware.h │ │ ├── UIDevice-Hardware.m │ │ ├── VdiskAccountInfo.h │ │ ├── VdiskAccountInfo.m │ │ ├── VdiskAuthorize.h │ │ ├── VdiskAuthorize.m │ │ ├── VdiskAuthorizeWebView.h │ │ ├── VdiskAuthorizeWebView.m │ │ ├── VdiskBase64 │ │ ├── VdiskBase64.h │ │ ├── VdiskBase64.m │ │ └── VdiskBase64Defines.h │ │ ├── VdiskComplexRequest.h │ │ ├── VdiskComplexRequest.m │ │ ├── VdiskComplexUpload.h │ │ ├── VdiskComplexUpload.m │ │ ├── VdiskDefines.h │ │ ├── VdiskDeltaEntry.h │ │ ├── VdiskDeltaEntry.m │ │ ├── VdiskError.h │ │ ├── VdiskError.m │ │ ├── VdiskKeychain.h │ │ ├── VdiskKeychain.m │ │ ├── VdiskLog.h │ │ ├── VdiskLog.m │ │ ├── VdiskMetadata.h │ │ ├── VdiskMetadata.m │ │ ├── VdiskQuota.h │ │ ├── VdiskQuota.m │ │ ├── VdiskRequest.h │ │ ├── VdiskRequest.m │ │ ├── VdiskRestClient.h │ │ ├── VdiskRestClient.m │ │ ├── VdiskSDK-Prefix.pch │ │ ├── VdiskSDK.h │ │ ├── VdiskSDKGlobal.h │ │ ├── VdiskSession.h │ │ ├── VdiskSession.m │ │ ├── VdiskSharesCategory.h │ │ ├── VdiskSharesCategory.m │ │ ├── VdiskSharesMetadata.h │ │ ├── VdiskSharesMetadata.m │ │ ├── VdiskUtil.h │ │ ├── VdiskUtil.m │ │ └── Weibo │ │ ├── JSONKit │ │ ├── JSONKit.h │ │ └── JSONKit.m │ │ ├── SinaWeibo.bundle │ │ └── images │ │ │ ├── close.png │ │ │ └── close@2x.png │ │ ├── SinaWeibo.h │ │ ├── SinaWeibo.m │ │ ├── SinaWeiboAuthorizeView.h │ │ ├── SinaWeiboAuthorizeView.m │ │ ├── SinaWeiboConstants.h │ │ ├── SinaWeiboRequest.h │ │ └── SinaWeiboRequest.m ├── WaveTransMetadata.h ├── WaveTransMetadata.mm ├── WaveTransModel.h ├── WaveTransModel.m └── view │ ├── AudioCell.h │ ├── AudioCell.m │ ├── AudioCell.xib │ ├── BinaryCell.h │ ├── BinaryCell.m │ ├── BinaryCell.xib │ ├── ContactsCell.h │ ├── ContactsCell.m │ ├── ContactsCell.xib │ ├── EGOImageView │ ├── EGOCache │ │ ├── EGOCache.h │ │ └── EGOCache.m │ ├── EGOImageLoader │ │ ├── EGOImageLoadConnection.h │ │ ├── EGOImageLoadConnection.m │ │ ├── EGOImageLoader.h │ │ └── EGOImageLoader.m │ ├── EGOImageView │ │ ├── EGOImageView.h │ │ └── EGOImageView.m │ ├── UIImage+UIImageScale.h │ └── UIImage+UIImageScale.m │ ├── MSCMoreOptionTableViewCell │ ├── MSCMoreOptionTableViewCell.h │ └── MSCMoreOptionTableViewCell.m │ ├── MainTableViewCell.h │ ├── MainTableViewCell.m │ ├── PhotoCell.h │ ├── PhotoCell.m │ ├── PhotoCell.xib │ ├── PureTextCell.h │ ├── PureTextCell.m │ ├── PureTextCell.xib │ ├── TableViewCellFactory.h │ ├── TableViewCellFactory.m │ ├── TextCell.h │ ├── TextCell.m │ ├── TextCell.xib │ ├── VideoCell.h │ ├── VideoCell.m │ ├── VideoCell.xib │ ├── WeiboCell.h │ ├── WeiboCell.m │ └── WeiboCell.xib ├── EAGLView.h ├── EAGLView.m ├── FileExt.plist ├── Images ├── 37x-Checkmark.png ├── 37x-Checkmark@2x.png ├── Default-568h@2x.png ├── SinaWeibo.bundle │ └── images │ │ ├── close.png │ │ └── close@2x.png ├── UITabBarContactsTemplate.png ├── UITabBarContactsTemplate@2x.png ├── X.png ├── X@2x.png ├── arrow_left@2x.png ├── arrow_right@2x.png ├── audio_bg.png ├── binary_bg.png ├── error.wav ├── icon.png ├── photo_cell_alpha_cover.png ├── play_beep.png ├── play_beep@2x.png ├── play_beep_disable.png ├── play_beep_disable@2x.png ├── play_btn.png ├── play_btn@2x.png ├── quotes_l.png ├── quotes_l@2x.png ├── quotes_r.png ├── quotes_r@2x.png ├── sent_btn.png ├── sent_btn@2x.png ├── setting_btn.png ├── setting_btn@2x.png ├── success_1.wav ├── tableview_sep_line.png ├── tableview_sep_line@2x.png ├── text_bg@2x.png ├── top_gb.png └── top_gb@2x.png ├── Info.plist ├── README.md ├── WaveTrans.xcodeproj └── project.pbxproj ├── WaveTrans └── Images.xcassets │ ├── AppIcon.appiconset │ ├── Contents.json │ ├── icon114.png │ ├── icon120.png │ └── icon57.png │ └── LaunchImage.launchimage │ ├── Contents.json │ ├── launchImage-568h@2x-1.png │ ├── launchImage-568h@2x.png │ ├── launchImage.png │ ├── launchImage@2x-1.png │ └── launchImage@2x.png ├── WaveTrans_Prefix.pch ├── aurio_helper.cpp ├── aurio_helper.h ├── fft ├── SpectrumAnalysis.cpp ├── SpectrumAnalysis.h ├── rad2fft.c └── rad2fft.h ├── freq_util ├── bb_freq_util.cpp ├── bb_freq_util.h └── bb_header.h ├── html ├── css │ ├── jquery.mobile.min.css │ └── main.css ├── images │ ├── bg-v3.png │ ├── cate_1.png │ ├── cate_13.png │ ├── cate_2.png │ ├── cate_20.png │ ├── cate_21.png │ ├── cate_23.png │ ├── cate_3.png │ ├── cate_4.png │ ├── cate_5.png │ ├── cate_6.png │ ├── cate_75.png │ ├── cate_guess_you_like.png │ ├── cate_other.png │ ├── ipad_doc_icon.png │ ├── ipad_doc_icon@2x.png │ ├── ipad_edu_icon.png │ ├── ipad_edu_icon@2x.png │ ├── ipad_it_icon.png │ ├── ipad_it_icon@2x.png │ ├── ipad_life_icon.png │ ├── ipad_life_icon@2x.png │ ├── ipad_random_icon.png │ ├── ipad_random_icon@2x.png │ ├── ipad_special.png │ └── ipad_special@2x.png ├── js │ ├── common.js │ ├── jquery.lazyload.min.js │ ├── jquery.min.js │ ├── jquery.mobile.min.js │ ├── jquery.scrollstop.js │ └── orientation.js └── text_reader.html ├── iPublicUtility ├── CABitOperations.h ├── CADebugMacros.cpp ├── CADebugMacros.h ├── CAMath.h ├── CAStreamBasicDescription.cpp ├── CAStreamBasicDescription.h ├── CAXException.cpp └── CAXException.h ├── kiss_fft ├── _kiss_fft_guts.h ├── kiss_fastfir.c ├── kiss_fastfir.h ├── kiss_fft.c ├── kiss_fft.h ├── kiss_fftr.c └── kiss_fftr.h ├── main.mm ├── queue ├── queue.cpp └── queue.h ├── rscode ├── rscode.cpp └── rscode.h └── temp_code ├── aaa.c ├── aaa.php └── bbb.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X Finder and whatnot 2 | .DS_Store 3 | 4 | # XCode (and ancestors) per-user config (very noisy, and not relevant) 5 | *.mode1 6 | *.mode1v3 7 | *.mode2v3 8 | *.perspective 9 | *.perspectivev3 10 | *.pbxuser 11 | xcuserdata 12 | *.xcworkspace 13 | 14 | # Generated files 15 | VersionX-revision.h 16 | 17 | 18 | # build products 19 | build/ 20 | *.[oa] 21 | 22 | # Other source repository archive directories (protects when importing) 23 | .hg 24 | .svn 25 | CVS 26 | *.DS_Store 27 | 28 | aaa 29 | -------------------------------------------------------------------------------- /ChoosePeopleViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChoosePeopleViewController.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-12-3. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface ChoosePeopleViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Classes/DDHTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // The MIT License (MIT) 3 | // 4 | // Copyright (c) 2013 Dominik Hauser 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | #import 25 | 26 | @interface DDHTextView : UITextView 27 | 28 | - (void)requireGestureRecognizerToFail:(UIGestureRecognizer*)gestureRecognizer; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/Database.h: -------------------------------------------------------------------------------- 1 | // 2 | // Database.h 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 13-2-5. 6 | // 7 | // 8 | 9 | #import 10 | #import "FMDatabaseQueue.h" 11 | #import "FMDatabase.h" 12 | 13 | @interface Database : NSObject 14 | 15 | //+ (Database *)sharedDatabase; 16 | - (FMResultSet *)executeQuery:(NSString *)sql; 17 | - (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments; 18 | - (BOOL)executeUpdate:(NSString *)sql; 19 | - (BOOL)executeUpdate:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments; 20 | 21 | @property (nonatomic, readonly) NSString *dbPath; 22 | @property (nonatomic, readonly) FMDatabase *database; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/Database.m: -------------------------------------------------------------------------------- 1 | // 2 | // Database.m 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 13-2-5. 6 | // 7 | // 8 | 9 | #import "Database.h" 10 | 11 | @interface Database () { 12 | 13 | NSString *_dbPath; 14 | FMDatabase *_database; 15 | } 16 | 17 | @end 18 | 19 | 20 | @implementation Database 21 | 22 | @synthesize dbPath = _dbPath; 23 | @synthesize database = _database; 24 | 25 | 26 | - (NSString *)documentsPath { 27 | 28 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 29 | 30 | if ([paths count] > 0) { 31 | 32 | return [paths objectAtIndex:0]; 33 | } 34 | 35 | return [NSHomeDirectory() stringByAppendingString:@"/Documents"]; 36 | } 37 | 38 | 39 | - (BOOL)createDirectory:(NSString *)path { 40 | 41 | NSFileManager *fileManager = [NSFileManager defaultManager]; 42 | NSString *fullPath = [[self documentsPath] stringByAppendingFormat:@"/%@", path]; 43 | BOOL isDir = NO; 44 | BOOL isExists = [fileManager fileExistsAtPath:fullPath isDirectory:&isDir]; 45 | 46 | if (!(isExists && isDir)) { 47 | 48 | return [fileManager createDirectoryAtPath:fullPath withIntermediateDirectories:YES attributes:nil error:nil]; 49 | 50 | } else { 51 | 52 | return YES; 53 | } 54 | } 55 | 56 | - (id)init { 57 | 58 | if (self = [super init]) { 59 | 60 | NSString *dbDirPath = @"userdata"; 61 | [self createDirectory:dbDirPath]; 62 | _dbPath = [[[self documentsPath] stringByAppendingFormat:@"/%@/userdata.sqlite", dbDirPath] retain]; 63 | _database = [[FMDatabase alloc] initWithPath:_dbPath]; 64 | 65 | /* DEBUG 66 | _database.traceExecution = YES; 67 | _database.logsErrors = YES; 68 | */ 69 | 70 | 71 | [_database open]; 72 | } 73 | 74 | return self; 75 | } 76 | 77 | - (void)dealloc { 78 | 79 | [_database close]; 80 | 81 | [_dbPath release], _dbPath = nil; 82 | [_database release], _database = nil; 83 | 84 | [super dealloc]; 85 | } 86 | 87 | 88 | 89 | 90 | - (FMResultSet *)executeQuery:(NSString *)sql { 91 | 92 | return [self.database executeQuery:sql]; 93 | } 94 | 95 | - (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments { 96 | 97 | return [self.database executeQuery:sql withParameterDictionary:arguments]; 98 | } 99 | 100 | 101 | - (BOOL)executeUpdate:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments { 102 | 103 | BOOL ret = NO; 104 | 105 | if (arguments == nil) { 106 | 107 | ret = [_database executeUpdate:sql]; 108 | 109 | } else { 110 | 111 | ret = [_database executeUpdate:sql withParameterDictionary:arguments]; 112 | } 113 | 114 | return ret; 115 | } 116 | 117 | - (BOOL)executeUpdate:(NSString *)sql { 118 | 119 | return [self executeUpdate:sql withParameterDictionary:nil]; 120 | } 121 | 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /Classes/FMDB/FMDatabaseAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMDatabaseAdditions.h 3 | // fmkit 4 | // 5 | // Created by August Mueller on 10/30/05. 6 | // Copyright 2005 Flying Meat Inc.. All rights reserved. 7 | // 8 | 9 | #import 10 | @interface FMDatabase (FMDatabaseAdditions) 11 | 12 | 13 | - (int)intForQuery:(NSString*)objs, ...; 14 | - (long)longForQuery:(NSString*)objs, ...; 15 | - (BOOL)boolForQuery:(NSString*)objs, ...; 16 | - (double)doubleForQuery:(NSString*)objs, ...; 17 | - (NSString*)stringForQuery:(NSString*)objs, ...; 18 | - (NSData*)dataForQuery:(NSString*)objs, ...; 19 | - (NSDate*)dateForQuery:(NSString*)objs, ...; 20 | 21 | // Notice that there's no dataNoCopyForQuery:. 22 | // That would be a bad idea, because we close out the result set, and then what 23 | // happens to the data that we just didn't copy? Who knows, not I. 24 | 25 | 26 | - (BOOL)tableExists:(NSString*)tableName; 27 | - (FMResultSet*)getSchema; 28 | - (FMResultSet*)getTableSchema:(NSString*)tableName; 29 | - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName; 30 | 31 | - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/FMDB/FMDatabasePool.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMDatabasePool.h 3 | // fmdb 4 | // 5 | // Created by August Mueller on 6/22/11. 6 | // Copyright 2011 Flying Meat Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "sqlite3.h" 11 | 12 | /* 13 | 14 | ***README OR SUFFER*** 15 | Before using FMDatabasePool, please consider using FMDatabaseQueue instead. 16 | 17 | If you really really really know what you're doing and FMDatabasePool is what 18 | you really really need (ie, you're using a read only database), OK you can use 19 | it. But just be careful not to deadlock! 20 | 21 | For an example on deadlocking, search for: 22 | ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS_OTHERWISE_YOULL_DEADLOCK_USE_FMDATABASEQUEUE_INSTEAD 23 | in the main.m file. 24 | 25 | */ 26 | 27 | 28 | 29 | @class FMDatabase; 30 | 31 | @interface FMDatabasePool : NSObject { 32 | NSString *_path; 33 | 34 | dispatch_queue_t _lockQueue; 35 | 36 | NSMutableArray *_databaseInPool; 37 | NSMutableArray *_databaseOutPool; 38 | 39 | __unsafe_unretained id _delegate; 40 | 41 | NSUInteger _maximumNumberOfDatabasesToCreate; 42 | } 43 | 44 | @property (retain) NSString *path; 45 | @property (assign) id delegate; 46 | @property (assign) NSUInteger maximumNumberOfDatabasesToCreate; 47 | 48 | + (id)databasePoolWithPath:(NSString*)aPath; 49 | - (id)initWithPath:(NSString*)aPath; 50 | 51 | - (NSUInteger)countOfCheckedInDatabases; 52 | - (NSUInteger)countOfCheckedOutDatabases; 53 | - (NSUInteger)countOfOpenDatabases; 54 | - (void)releaseAllDatabases; 55 | 56 | - (void)inDatabase:(void (^)(FMDatabase *db))block; 57 | 58 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; 59 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; 60 | 61 | #if SQLITE_VERSION_NUMBER >= 3007000 62 | // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. 63 | // If you need to nest, use FMDatabase's startSavePointWithName:error: instead. 64 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block; 65 | #endif 66 | 67 | @end 68 | 69 | 70 | @interface NSObject (FMDatabasePoolDelegate) 71 | 72 | - (BOOL)databasePool:(FMDatabasePool*)pool shouldAddDatabaseToPool:(FMDatabase*)database; 73 | 74 | @end 75 | 76 | -------------------------------------------------------------------------------- /Classes/FMDB/FMDatabaseQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // FMDatabasePool.h 3 | // fmdb 4 | // 5 | // Created by August Mueller on 6/22/11. 6 | // Copyright 2011 Flying Meat Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "sqlite3.h" 11 | 12 | @class FMDatabase; 13 | 14 | @interface FMDatabaseQueue : NSObject { 15 | NSString *_path; 16 | dispatch_queue_t _queue; 17 | FMDatabase *_db; 18 | } 19 | 20 | @property (retain) NSString *path; 21 | 22 | + (id)databaseQueueWithPath:(NSString*)aPath; 23 | - (id)initWithPath:(NSString*)aPath; 24 | - (void)close; 25 | 26 | - (void)inDatabase:(void (^)(FMDatabase *db))block; 27 | 28 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; 29 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; 30 | 31 | #if SQLITE_VERSION_NUMBER >= 3007000 32 | // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. 33 | // If you need to nest, use FMDatabase's startSavePointWithName:error: instead. 34 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block; 35 | #endif 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /Classes/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @class WaveTransMetadata; 12 | 13 | @interface MainViewController : UIViewController 14 | @property (nonatomic, assign) BOOL playFlag; 15 | @end 16 | 17 | @protocol MainViewControllerDelegate 18 | //更新下载进度 19 | - (void)updateDownloadProgress:(CGFloat)progress byMetadata:(WaveTransMetadata *)metadata; 20 | 21 | @end 22 | 23 | 24 | @protocol PostWaveTransMetadataDelegate 25 | 26 | - (void)postWaveTransMetadata:(WaveTransMetadata *)metadata; 27 | 28 | @end -------------------------------------------------------------------------------- /Classes/PlayPCM/PCMRender.h: -------------------------------------------------------------------------------- 1 | // 2 | // PCMRender.h 3 | // PlayPCM 4 | // 5 | // Created by hanchao on 13-11-22. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PCMRender : NSObject 12 | 13 | + (NSData *)renderChirpData:(NSString *)serializeStr; 14 | + (void)switchFreq:(BOOL)isHigh; 15 | + (BOOL)isHighFreq; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Classes/PlayPCM/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PlayPCM 4 | // 5 | // Created by hanchao on 13-11-21. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ViewController : UIViewController 13 | 14 | @property (nonatomic,strong) AVAudioPlayer *audioPlayer; 15 | 16 | @property (nonatomic,strong) IBOutlet UILabel *freqlabel; 17 | -(IBAction)playAction:(id)sender; 18 | 19 | -(IBAction)sliderEvent:(id)sender; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Classes/PlayPCM/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PlayPCM 4 | // 5 | // Created by hanchao on 13-11-21. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #import 12 | 13 | #import "PCMRender.h" 14 | 15 | @interface ViewController () 16 | 17 | @property (nonatomic,assign) NSInteger freqNum; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | // Do any additional setup after loading the view, typically from a nib. 27 | } 28 | 29 | -(IBAction)sliderEvent:(UISlider *)slider 30 | { 31 | self.freqNum = (NSInteger)slider.value; 32 | self.freqlabel.text = [NSString stringWithFormat:@"%d",(NSInteger)slider.value]; 33 | } 34 | 35 | 36 | - (void)didReceiveMemoryWarning 37 | { 38 | [super didReceiveMemoryWarning]; 39 | // Dispose of any resources that can be recreated. 40 | } 41 | 42 | -(IBAction)playAction:(id)sender         43 | { 44 | NSData *pcmData = [PCMRender renderChirpData:@"abcdefghijklmnopqrstuv"]; 45 | 46 | NSError *error; 47 | self.audioPlayer = [[AVAudioPlayer alloc] initWithData:pcmData 48 | error:&error]; 49 | 50 | if (error) { 51 | NSLog(@"error....%@",[error localizedDescription]); 52 | }else{ 53 | self.audioPlayer.delegate = self; 54 | [self.audioPlayer prepareToPlay]; 55 | } 56 | 57 | [self.audioPlayer play]; 58 | 59 | 60 | 61 | } 62 | 63 | #pragma mark - AVAudioPlayerDelegate 64 | 65 | /* audioPlayerDidFinishPlaying:successfully: is called when a sound has finished playing. This method is NOT called if the player is stopped due to an interruption. */ 66 | - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag 67 | { 68 | 69 | } 70 | 71 | /* if an error occurs while decoding it will be reported to the delegate. */ 72 | - (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error 73 | { 74 | 75 | } 76 | 77 | /* audioPlayerBeginInterruption: is called when the audio session has been interrupted while the player was playing. The player will have been paused. */ 78 | - (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player 79 | { 80 | 81 | } 82 | 83 | /* audioPlayerEndInterruption: is called when the preferred method, audioPlayerEndInterruption:withFlags:, is not implemented. */ 84 | - (void)audioPlayerEndInterruption:(AVAudioPlayer *)player 85 | { 86 | 87 | } 88 | @end 89 | -------------------------------------------------------------------------------- /Classes/RootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.h 3 | // aurioTouch2 4 | // 5 | // Created by Littlebox222 on 13-11-22. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class WaveTransMetadata; 13 | @protocol PostWaveTransMetadataDelegate; 14 | 15 | 16 | @interface RootViewController : UIViewController 17 | 18 | 19 | @end -------------------------------------------------------------------------------- /Classes/TextEditorViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextEditorViewController.h 3 | // WaveTrans 4 | // 5 | // Created by Bruce on 13-11-26. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @protocol PostWaveTransMetadataDelegate; 12 | 13 | @interface TextEditorViewController : UIViewController 14 | 15 | @property (nonatomic, assign) id postWaveTransMetadataDelegate; 16 | 17 | @end -------------------------------------------------------------------------------- /Classes/TextViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextViewController.h 3 | // WaveTrans 4 | // 5 | // Created by Bruce on 13-11-27. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface TextViewController : UIViewController 12 | 13 | @property (nonatomic, retain) NSString *contentText; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/TextViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TextViewController.m 3 | // WaveTrans 4 | // 5 | // Created by Bruce on 13-11-27. 6 | // 7 | // 8 | 9 | #import "TextViewController.h" 10 | #import "VdiskJSON.h" 11 | 12 | @interface TextViewController () { 13 | 14 | UIWebView *_webView; 15 | } 16 | 17 | @end 18 | 19 | @implementation TextViewController 20 | 21 | @synthesize contentText = _contentText; 22 | 23 | 24 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 25 | 26 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 27 | 28 | if (self) { 29 | 30 | } 31 | 32 | 33 | return self; 34 | } 35 | 36 | - (void)close { 37 | 38 | [self.navigationController dismissViewControllerAnimated:YES completion:^{ 39 | 40 | }]; 41 | } 42 | 43 | - (void)copyText { 44 | 45 | UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 46 | [pasteboard setString:_contentText]; 47 | } 48 | 49 | - (void)viewDidLoad { 50 | 51 | [super viewDidLoad]; 52 | 53 | _webView = [[UIWebView alloc] initWithFrame:self.view.frame]; 54 | [self.view addSubview:_webView]; 55 | _webView.delegate = self; 56 | 57 | [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"html/text_reader.html" ofType:nil]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0]]; 58 | 59 | 60 | self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(close)] autorelease]; 61 | self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"复制文本" style:UIBarButtonItemStylePlain target:self action:@selector(copyText)] autorelease]; 62 | } 63 | 64 | 65 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 66 | 67 | NSLog(@"%@", _contentText); 68 | 69 | [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"display_text(%@)", [@{@"text":_contentText} JSONRepresentation]]]; 70 | } 71 | 72 | - (void)didReceiveMemoryWarning { 73 | 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | - (void)dealloc { 79 | 80 | [_contentText release]; 81 | 82 | [_webView stopLoading]; 83 | _webView.delegate = nil; 84 | [_webView release]; 85 | 86 | [super dealloc]; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Classes/VdiskError__.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | /* This file contains error codes and the Vdisk error domain */ 20 | 21 | //extern NSString *kVdiskErrorDomain; 22 | 23 | /* 24 | // Error codes in the vdisk.weibo.com domain represent the HTTP status code if less than 1000 25 | typedef enum { 26 | 27 | kVdiskErrorNone = 0, 28 | kVdiskErrorGenericError = 1000, 29 | kVdiskErrorFileNotFound = 1001, 30 | kVdiskErrorInsufficientDiskSpace = 1002, 31 | kVdiskErrorIllegalFileType = 1003, // Error sent if you try to upload a directory 32 | kVdiskErrorInvalidResponse = 1004, // Sent when the client does not get valid JSON when it's expecting it, 或者json解析成功了,但是返回内容和文档不一致,或者缺少对应的字段 33 | kVdiskErrorSessionError = 1005, 34 | kVdiskErrorFileContentLengthNotMatch = 1006, // 下载文件的大小和http响应头Content-Length不一致 35 | kVdiskErrorGetFileAttributesFailure = 1007, // 获得文件属性失败 36 | kVdiskErrorS3URLExpired = 1008, // S3下载链接过期 37 | kVdiskErrorMd5NotMatched = 1009, // 大文件分片上传一段文件后,服务器返回的该段文件md5和本地该段文件md5不匹配 38 | 39 | } kVdiskErrorCode; 40 | 41 | 42 | 43 | typedef enum { 44 | 45 | kVdiskErrorLevelUnknown = 0, 46 | kVdiskErrorLevelNetwork = 10, 47 | kVdiskErrorLevelHTTP = 100, 48 | kVdiskErrorLevelLocal = 1000, 49 | kVdiskErrorLevelAPI = 10000, 50 | 51 | } kVdiskErrorLevel; 52 | */ 53 | 54 | kVdiskErrorLevel VdiskErrorParseErrorLevel__(NSError *error); 55 | NSUInteger VdiskErrorParseErrorCode__(NSError *error); 56 | NSString *VdiskErrorMessageWithCode__(NSError *error); 57 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIAuthenticationDialog.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIAuthenticationDialog.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 21/08/2009. 6 | // Copyright 2009 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @class ASIHTTPRequest; 12 | 13 | typedef enum _ASIAuthenticationType { 14 | ASIStandardAuthenticationType = 0, 15 | ASIProxyAuthenticationType = 1 16 | } ASIAuthenticationType; 17 | 18 | @interface ASIAutorotatingViewController : UIViewController 19 | @end 20 | 21 | @interface ASIAuthenticationDialog : ASIAutorotatingViewController { 22 | ASIHTTPRequest *request; 23 | ASIAuthenticationType type; 24 | UITableView *tableView; 25 | UIViewController *presentingController; 26 | BOOL didEnableRotationNotifications; 27 | } 28 | + (void)presentAuthenticationDialogForRequest:(ASIHTTPRequest *)request; 29 | + (void)dismiss; 30 | 31 | @property (retain) ASIHTTPRequest *request; 32 | @property (assign) ASIAuthenticationType type; 33 | @property (assign) BOOL didEnableRotationNotifications; 34 | @property (retain, nonatomic) UIViewController *presentingController; 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIDataCompressor.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIDataCompressor.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 17/08/2010. 6 | // Copyright 2010 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | // This is a helper class used by ASIHTTPRequest to handle deflating (compressing) data in memory and on disk 10 | // You may also find it helpful if you need to deflate data and files yourself - see the class methods below 11 | // Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net 12 | 13 | #import 14 | #import 15 | 16 | @interface ASIDataCompressor : NSObject { 17 | BOOL streamReady; 18 | z_stream zStream; 19 | } 20 | 21 | // Convenience constructor will call setupStream for you 22 | + (id)compressor; 23 | 24 | // Compress the passed chunk of data 25 | // Passing YES for shouldFinish will finalize the deflated data - you must pass YES when you are on the last chunk of data 26 | - (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish; 27 | 28 | // Convenience method - pass it some data, and you'll get deflated data back 29 | + (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err; 30 | 31 | // Convenience method - pass it a file containing the data to compress in sourcePath, and it will write deflated data to destinationPath 32 | + (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err; 33 | 34 | // Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'compressor' 35 | - (NSError *)setupStream; 36 | 37 | // Tells zlib to clean up. You need to call this if you need to cancel deflating part way through 38 | // If deflating finishes or fails, this method will be called automatically 39 | - (NSError *)closeStream; 40 | 41 | @property (assign, readonly) BOOL streamReady; 42 | @end 43 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIDataDecompressor.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIDataDecompressor.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 17/08/2010. 6 | // Copyright 2010 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | // This is a helper class used by ASIHTTPRequest to handle inflating (decompressing) data in memory and on disk 10 | // You may also find it helpful if you need to inflate data and files yourself - see the class methods below 11 | // Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net 12 | 13 | #import 14 | #import 15 | 16 | @interface ASIDataDecompressor : NSObject { 17 | BOOL streamReady; 18 | z_stream zStream; 19 | } 20 | 21 | // Convenience constructor will call setupStream for you 22 | + (id)decompressor; 23 | 24 | // Uncompress the passed chunk of data 25 | - (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err; 26 | 27 | // Convenience method - pass it some deflated data, and you'll get inflated data back 28 | + (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err; 29 | 30 | // Convenience method - pass it a file containing deflated data in sourcePath, and it will write inflated data to destinationPath 31 | + (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err; 32 | 33 | // Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'decompressor' 34 | - (NSError *)setupStream; 35 | 36 | // Tells zlib to clean up. You need to call this if you need to cancel inflating part way through 37 | // If inflating finishes or fails, this method will be called automatically 38 | - (NSError *)closeStream; 39 | 40 | @property (assign, readonly) BOOL streamReady; 41 | @end 42 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIDownloadCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIDownloadCache.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 01/05/2010. 6 | // Copyright 2010 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ASICacheDelegate.h" 11 | 12 | @interface ASIDownloadCache : NSObject { 13 | 14 | // The default cache policy for this cache 15 | // Requests that store data in the cache will use this cache policy if their cache policy is set to ASIUseDefaultCachePolicy 16 | // Defaults to ASIAskServerIfModifiedWhenStaleCachePolicy 17 | ASICachePolicy defaultCachePolicy; 18 | 19 | // The directory in which cached data will be stored 20 | // Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory 21 | NSString *storagePath; 22 | 23 | // Mediates access to the cache 24 | NSRecursiveLock *accessLock; 25 | 26 | // When YES, the cache will look for cache-control / pragma: no-cache headers, and won't reuse store responses if it finds them 27 | BOOL shouldRespectCacheControlHeaders; 28 | } 29 | 30 | // Returns a static instance of an ASIDownloadCache 31 | // In most circumstances, it will make sense to use this as a global cache, rather than creating your own cache 32 | // To make ASIHTTPRequests use it automatically, use [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]]; 33 | + (id)sharedCache; 34 | 35 | // A helper function that determines if the server has requested data should not be cached by looking at the request's response headers 36 | + (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request; 37 | 38 | // A list of file extensions that we know won't be readable by a webview when accessed locally 39 | // If we're asking for a path to cache a particular url and it has one of these extensions, we change it to '.html' 40 | + (NSArray *)fileExtensionsToHandleAsHTML; 41 | 42 | @property (assign, nonatomic) ASICachePolicy defaultCachePolicy; 43 | @property (retain, nonatomic) NSString *storagePath; 44 | @property (retain) NSRecursiveLock *accessLock; 45 | @property (assign) BOOL shouldRespectCacheControlHeaders; 46 | @end 47 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIFormDataRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIFormDataRequest.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 07/11/2008. 6 | // Copyright 2008-2009 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ASIHTTPRequest.h" 11 | #import "ASIHTTPRequestConfig.h" 12 | 13 | typedef enum _ASIPostFormat { 14 | ASIMultipartFormDataPostFormat = 0, 15 | ASIURLEncodedPostFormat = 1 16 | 17 | } ASIPostFormat; 18 | 19 | @interface ASIFormDataRequest : ASIHTTPRequest { 20 | 21 | // Parameters that will be POSTed to the url 22 | NSMutableArray *postData; 23 | 24 | // Files that will be POSTed to the url 25 | NSMutableArray *fileData; 26 | 27 | ASIPostFormat postFormat; 28 | 29 | NSStringEncoding stringEncoding; 30 | 31 | #if DEBUG_FORM_DATA_REQUEST 32 | // Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS 33 | NSString *debugBodyString; 34 | #endif 35 | 36 | } 37 | 38 | #pragma mark utilities 39 | - (NSString*)encodeURL:(NSString *)string; 40 | 41 | #pragma mark setup request 42 | 43 | // Add a POST variable to the request 44 | - (void)addPostValue:(id )value forKey:(NSString *)key; 45 | 46 | // Set a POST variable for this request, clearing any others with the same key 47 | - (void)setPostValue:(id )value forKey:(NSString *)key; 48 | 49 | // Add the contents of a local file to the request 50 | - (void)addFile:(NSString *)filePath forKey:(NSString *)key; 51 | 52 | // Same as above, but you can specify the content-type and file name 53 | - (void)addFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key; 54 | 55 | // Add the contents of a local file to the request, clearing any others with the same key 56 | - (void)setFile:(NSString *)filePath forKey:(NSString *)key; 57 | 58 | // Same as above, but you can specify the content-type and file name 59 | - (void)setFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key; 60 | 61 | // Add the contents of an NSData object to the request 62 | - (void)addData:(NSData *)data forKey:(NSString *)key; 63 | 64 | // Same as above, but you can specify the content-type and file name 65 | - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key; 66 | 67 | // Add the contents of an NSData object to the request, clearing any others with the same key 68 | - (void)setData:(NSData *)data forKey:(NSString *)key; 69 | 70 | // Same as above, but you can specify the content-type and file name 71 | - (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key; 72 | 73 | 74 | @property (assign) ASIPostFormat postFormat; 75 | @property (assign) NSStringEncoding stringEncoding; 76 | @end 77 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIHTTPRequestConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIHTTPRequestConfig.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 14/12/2009. 6 | // Copyright 2009 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | 10 | // ====== 11 | // Debug output configuration options 12 | // ====== 13 | 14 | // If defined will use the specified function for debug logging 15 | // Otherwise use NSLog 16 | #ifndef ASI_DEBUG_LOG 17 | #define ASI_DEBUG_LOG NSLog 18 | #endif 19 | 20 | // When set to 1 ASIHTTPRequests will print information about what a request is doing 21 | #ifndef DEBUG_REQUEST_STATUS 22 | #define DEBUG_REQUEST_STATUS 0 23 | #endif 24 | 25 | // When set to 1, ASIFormDataRequests will print information about the request body to the console 26 | #ifndef DEBUG_FORM_DATA_REQUEST 27 | #define DEBUG_FORM_DATA_REQUEST 0 28 | #endif 29 | 30 | // When set to 1, ASIHTTPRequests will print information about bandwidth throttling to the console 31 | #ifndef DEBUG_THROTTLING 32 | #define DEBUG_THROTTLING 0 33 | #endif 34 | 35 | // When set to 1, ASIHTTPRequests will print information about persistent connections to the console 36 | #ifndef DEBUG_PERSISTENT_CONNECTIONS 37 | #define DEBUG_PERSISTENT_CONNECTIONS 0 38 | #endif 39 | 40 | // When set to 1, ASIHTTPRequests will print information about HTTP authentication (Basic, Digest or NTLM) to the console 41 | #ifndef DEBUG_HTTP_AUTHENTICATION 42 | #define DEBUG_HTTP_AUTHENTICATION 0 43 | #endif 44 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIHTTPRequestDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIHTTPRequestDelegate.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 13/04/2010. 6 | // Copyright 2010 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | @class ASIHTTPRequest; 10 | 11 | @protocol ASIHTTPRequestDelegate 12 | 13 | @optional 14 | 15 | // These are the default delegate methods for request status 16 | // You can use different ones by setting didStartSelector / didFinishSelector / didFailSelector 17 | - (void)requestStarted:(ASIHTTPRequest *)request; 18 | - (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders; 19 | - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL; 20 | - (void)requestFinished:(ASIHTTPRequest *)request; 21 | - (void)requestFailed:(ASIHTTPRequest *)request; 22 | - (void)requestRedirected:(ASIHTTPRequest *)request; 23 | 24 | // When a delegate implements this method, it is expected to process all incoming data itself 25 | // This means that responseData / responseString / downloadDestinationPath etc are ignored 26 | // You can have the request call a different method by setting didReceiveDataSelector 27 | - (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data; 28 | 29 | // If a delegate implements one of these, it will be asked to supply credentials when none are available 30 | // The delegate can then either restart the request ([request retryUsingSuppliedCredentials]) once credentials have been set 31 | // or cancel it ([request cancelAuthentication]) 32 | - (void)authenticationNeededForRequest:(ASIHTTPRequest *)request; 33 | - (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIInputStream.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIInputStream.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 10/08/2009. 6 | // Copyright 2009 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ASIHTTPRequest; 12 | 13 | // This is a wrapper for NSInputStream that pretends to be an NSInputStream itself 14 | // Subclassing NSInputStream seems to be tricky, and may involve overriding undocumented methods, so we'll cheat instead. 15 | // It is used by ASIHTTPRequest whenever we have a request body, and handles measuring and throttling the bandwidth used for uploading 16 | 17 | @interface ASIInputStream : NSObject { 18 | NSInputStream *stream; 19 | ASIHTTPRequest *request; 20 | } 21 | + (id)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)request; 22 | + (id)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)request; 23 | 24 | @property (retain, nonatomic) NSInputStream *stream; 25 | @property (assign, nonatomic) ASIHTTPRequest *request; 26 | @end 27 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/ASIHttpRequest/ASIProgressDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASIProgressDelegate.h 3 | // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest 4 | // 5 | // Created by Ben Copsey on 13/04/2010. 6 | // Copyright 2010 All-Seeing Interactive. All rights reserved. 7 | // 8 | 9 | @class ASIHTTPRequest; 10 | 11 | @protocol ASIProgressDelegate 12 | 13 | @optional 14 | 15 | // These methods are used to update UIProgressViews (iPhone OS) or NSProgressIndicators (Mac OS X) 16 | // If you are using a custom progress delegate, you may find it easier to implement didReceiveBytes / didSendBytes instead 17 | #if TARGET_OS_IPHONE 18 | - (void)setProgress:(float)newProgress; 19 | #else 20 | - (void)setDoubleValue:(double)newProgress; 21 | - (void)setMaxValue:(double)newMax; 22 | #endif 23 | 24 | // Called when the request receives some data - bytes is the length of that data 25 | - (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes; 26 | 27 | // Called when the request sends some data 28 | // The first 32KB (128KB on older platforms) of data sent is not included in this amount because of limitations with the CFNetwork API 29 | // bytes may be less than zero if a request needs to remove upload progress (probably because the request needs to run again) 30 | - (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes; 31 | 32 | // Called when a request needs to change the length of the content to download 33 | - (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength; 34 | 35 | // Called when a request needs to change the length of the content to upload 36 | // newLength may be less than zero when a request needs to remove the size of the internal buffer from progress tracking 37 | - (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength; 38 | @end 39 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/NSObject+VdiskJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | 33 | /** 34 | @brief Adds JSON generation to Foundation classes 35 | 36 | This is a category on NSObject that adds methods for returning JSON representations 37 | of standard objects to the objects themselves. This means you can call the 38 | -JSONRepresentation method on an NSArray object and it'll do what you want. 39 | */ 40 | @interface NSObject (NSObject_VdiskJSON) 41 | 42 | /** 43 | @brief Returns a string containing the receiver encoded as a JSON fragment. 44 | 45 | This method is added as a category on NSObject but is only actually 46 | supported for the following objects: 47 | @li NSDictionary 48 | @li NSArray 49 | @li NSString 50 | @li NSNumber (also used for booleans) 51 | @li NSNull 52 | 53 | @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed. 54 | */ 55 | - (NSString *)JSONFragment; 56 | 57 | /** 58 | @brief Returns a string containing the receiver encoded in JSON. 59 | 60 | This method is added as a category on NSObject but is only actually 61 | supported for the following objects: 62 | @li NSDictionary 63 | @li NSArray 64 | */ 65 | - (NSString *)JSONRepresentation; 66 | 67 | @end 68 | 69 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/NSObject+VdiskJSON.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "NSObject+VdiskJSON.h" 31 | #import "VdiskJsonWriter.h" 32 | 33 | #import "VdiskDefines.h" 34 | 35 | 36 | @implementation NSObject (NSObject_VdiskJSON) 37 | 38 | - (NSString *)JSONFragment { 39 | 40 | VdiskJsonWriter *jsonWriter = [VdiskJsonWriter new]; 41 | NSString *json = [jsonWriter stringWithFragment:self]; 42 | 43 | if (!json) 44 | NSLog(@"-JSONFragment failed. Error trace is: %@", [jsonWriter errorTrace]); 45 | 46 | [jsonWriter release]; 47 | return json; 48 | } 49 | 50 | - (NSString *)JSONRepresentation { 51 | 52 | VdiskJsonWriter *jsonWriter = [VdiskJsonWriter new]; 53 | NSString *json = [jsonWriter stringWithObject:self]; 54 | 55 | if (!json) 56 | NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]); 57 | 58 | [jsonWriter release]; 59 | return json; 60 | } 61 | 62 | @end 63 | 64 | VDISK_FIX_CATEGORY_BUG(NSObject_VdiskJSON) 65 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/NSString+VdiskJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | /** 33 | @brief Adds JSON parsing methods to NSString 34 | 35 | This is a category on NSString that adds methods for parsing the target string. 36 | */ 37 | @interface NSString (NSString_VdiskJSON) 38 | 39 | 40 | /** 41 | @brief Returns the object represented in the receiver, or nil on error. 42 | 43 | Returns a a scalar object represented by the string's JSON fragment representation. 44 | 45 | @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed. 46 | */ 47 | - (id)JSONFragmentValue; 48 | 49 | /** 50 | @brief Returns the NSDictionary or NSArray represented by the current string's JSON representation. 51 | 52 | Returns the dictionary or array represented in the receiver, or nil on error. 53 | 54 | Returns the NSDictionary or NSArray represented by the current string's JSON representation. 55 | */ 56 | - (id)JSONValue; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/NSString+VdiskJSON.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "NSString+VdiskJSON.h" 31 | #import "VdiskJsonParser.h" 32 | 33 | #import "VdiskDefines.h" 34 | 35 | 36 | @implementation NSString (NSString_VdiskJSON) 37 | 38 | - (id)JSONFragmentValue 39 | { 40 | VdiskJsonParser *jsonParser = [VdiskJsonParser new]; 41 | id repr = [jsonParser fragmentWithString:self]; 42 | if (!repr) 43 | NSLog(@"-JSONFragmentValue failed. Error trace is: %@", [jsonParser errorTrace]); 44 | [jsonParser release]; 45 | return repr; 46 | } 47 | 48 | - (id)JSONValue 49 | { 50 | VdiskJsonParser *jsonParser = [VdiskJsonParser new]; 51 | id repr = [jsonParser objectWithString:self]; 52 | if (!repr) 53 | NSLog(@"-JSONValue failed. Error trace is: %@", [jsonParser errorTrace]); 54 | [jsonParser release]; 55 | return repr; 56 | } 57 | 58 | @end 59 | 60 | VDISK_FIX_CATEGORY_BUG(NSString_VdiskJSON) 61 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/VdiskJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | #import "VdiskJsonParser.h" 32 | #import "VdiskJsonWriter.h" 33 | #import "NSObject+VdiskJSON.h" 34 | #import "NSString+VdiskJSON.h" 35 | 36 | /** 37 | @brief Facade for VdiskJsonWriter/VdiskJsonParser. 38 | 39 | Requests are forwarded to instances of VdiskJsonWriter and VdiskJsonParser. 40 | */ 41 | @interface VdiskJSON : VdiskJsonBase { 42 | 43 | @private 44 | VdiskJsonParser *jsonParser; 45 | VdiskJsonWriter *jsonWriter; 46 | } 47 | 48 | 49 | /// Return the fragment represented by the given string 50 | - (id)fragmentWithString:(NSString*)jsonrep 51 | error:(NSError**)error; 52 | 53 | /// Return the object represented by the given string 54 | - (id)objectWithString:(NSString*)jsonrep 55 | error:(NSError**)error; 56 | 57 | /// Parse the string and return the represented object (or scalar) 58 | - (id)objectWithString:(id)value 59 | allowScalar:(BOOL)x 60 | error:(NSError**)error; 61 | 62 | 63 | /// Return JSON representation of an array or dictionary 64 | - (NSString*)stringWithObject:(id)value 65 | error:(NSError**)error; 66 | 67 | /// Return JSON representation of any legal JSON value 68 | - (NSString*)stringWithFragment:(id)value 69 | error:(NSError**)error; 70 | 71 | /// Return JSON representation (or fragment) for the given object 72 | - (NSString*)stringWithObject:(id)value 73 | allowScalar:(BOOL)x 74 | error:(NSError**)error; 75 | 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/VdiskJsonBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | extern NSString * kVdiskJSONErrorDomain; 33 | 34 | 35 | enum { 36 | EUNSUPPORTED = 1, 37 | EPARSENUM, 38 | EPARSE, 39 | EFRAGMENT, 40 | ECTRL, 41 | EUNICODE, 42 | EDEPTH, 43 | EESCAPE, 44 | ETRAILCOMMA, 45 | ETRAILGARBAGE, 46 | EEOF, 47 | EINPUT 48 | }; 49 | 50 | /** 51 | @brief Common base class for parsing & writing. 52 | 53 | This class contains the common error-handling code and option between the parser/writer. 54 | */ 55 | @interface VdiskJsonBase : NSObject { 56 | NSMutableArray *errorTrace; 57 | 58 | @protected 59 | NSUInteger depth, maxDepth; 60 | } 61 | 62 | /** 63 | @brief The maximum recursing depth. 64 | 65 | Defaults to 512. If the input is nested deeper than this the input will be deemed to be 66 | malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can 67 | turn off this security feature by setting the maxDepth value to 0. 68 | */ 69 | @property NSUInteger maxDepth; 70 | 71 | /** 72 | @brief Return an error trace, or nil if there was no errors. 73 | 74 | Note that this method returns the trace of the last method that failed. 75 | You need to check the return value of the call you're making to figure out 76 | if the call actually failed, before you know call this method. 77 | */ 78 | @property(copy,readonly) NSArray* errorTrace; 79 | 80 | /// @internal for use in subclasses to add errors to the stack trace 81 | - (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str; 82 | 83 | /// @internal for use in subclasess to clear the error before a new parsing attempt 84 | - (void)clearErrorTrace; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/JSON/VdiskJsonBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "VdiskJsonBase.h" 31 | NSString * kVdiskJSONErrorDomain = @"org.brautaset.JSON.ErrorDomain"; 32 | 33 | 34 | @implementation VdiskJsonBase 35 | 36 | @synthesize errorTrace; 37 | @synthesize maxDepth; 38 | 39 | - (id)init { 40 | self = [super init]; 41 | if (self) 42 | self.maxDepth = 512; 43 | return self; 44 | } 45 | 46 | - (void)dealloc { 47 | [errorTrace release]; 48 | [super dealloc]; 49 | } 50 | 51 | - (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str { 52 | NSDictionary *userInfo; 53 | if (!errorTrace) { 54 | errorTrace = [NSMutableArray new]; 55 | userInfo = [NSDictionary dictionaryWithObject:str forKey:NSLocalizedDescriptionKey]; 56 | 57 | } else { 58 | userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 59 | str, NSLocalizedDescriptionKey, 60 | [errorTrace lastObject], NSUnderlyingErrorKey, 61 | nil]; 62 | } 63 | 64 | NSError *error = [NSError errorWithDomain:kVdiskJSONErrorDomain code:code userInfo:userInfo]; 65 | 66 | [self willChangeValueForKey:@"errorTrace"]; 67 | [errorTrace addObject:error]; 68 | [self didChangeValueForKey:@"errorTrace"]; 69 | } 70 | 71 | - (void)clearErrorTrace { 72 | 73 | [self willChangeValueForKey:@"errorTrace"]; 74 | [errorTrace release]; 75 | errorTrace = nil; 76 | [self didChangeValueForKey:@"errorTrace"]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/DDASLLogger.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import "DDLog.h" 5 | 6 | /** 7 | * Welcome to Cocoa Lumberjack! 8 | * 9 | * The project page has a wealth of documentation if you have any questions. 10 | * https://github.com/robbiehanson/CocoaLumberjack 11 | * 12 | * If you're new to the project you may wish to read the "Getting Started" wiki. 13 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted 14 | * 15 | * 16 | * This class provides a logger for the Apple System Log facility. 17 | * 18 | * As described in the "Getting Started" page, 19 | * the traditional NSLog() function directs it's output to two places: 20 | * 21 | * - Apple System Log 22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console 23 | * 24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger. 25 | * However, if you instead choose to use file logging (for faster performance), 26 | * you may choose to use a file logger and a tty logger. 27 | **/ 28 | 29 | @interface DDASLLogger : DDAbstractLogger 30 | { 31 | aslclient client; 32 | } 33 | 34 | + (DDASLLogger *)sharedInstance; 35 | 36 | // Inherited from DDAbstractLogger 37 | 38 | // - (id )logFormatter; 39 | // - (void)setLogFormatter:(id )formatter; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/DDASLLogger.m: -------------------------------------------------------------------------------- 1 | #import "DDASLLogger.h" 2 | 3 | #import 4 | 5 | /** 6 | * Welcome to Cocoa Lumberjack! 7 | * 8 | * The project page has a wealth of documentation if you have any questions. 9 | * https://github.com/robbiehanson/CocoaLumberjack 10 | * 11 | * If you're new to the project you may wish to read the "Getting Started" wiki. 12 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted 13 | **/ 14 | 15 | #if ! __has_feature(objc_arc) 16 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC). 17 | #endif 18 | 19 | 20 | @implementation DDASLLogger 21 | 22 | static DDASLLogger *sharedInstance; 23 | 24 | /** 25 | * The runtime sends initialize to each class in a program exactly one time just before the class, 26 | * or any class that inherits from it, is sent its first message from within the program. (Thus the 27 | * method may never be invoked if the class is not used.) The runtime sends the initialize message to 28 | * classes in a thread-safe manner. Superclasses receive this message before their subclasses. 29 | * 30 | * This method may also be called directly (assumably by accident), hence the safety mechanism. 31 | **/ 32 | + (void)initialize 33 | { 34 | static BOOL initialized = NO; 35 | if (!initialized) 36 | { 37 | initialized = YES; 38 | 39 | sharedInstance = [[DDASLLogger alloc] init]; 40 | } 41 | } 42 | 43 | + (DDASLLogger *)sharedInstance 44 | { 45 | return sharedInstance; 46 | } 47 | 48 | - (id)init 49 | { 50 | if (sharedInstance != nil) 51 | { 52 | return nil; 53 | } 54 | 55 | if ((self = [super init])) 56 | { 57 | // A default asl client is provided for the main thread, 58 | // but background threads need to create their own client. 59 | 60 | client = asl_open(NULL, "com.apple.console", 0); 61 | } 62 | return self; 63 | } 64 | 65 | - (void)logMessage:(DDLogMessage *)logMessage 66 | { 67 | NSString *logMsg = logMessage->logMsg; 68 | 69 | if (formatter) 70 | { 71 | logMsg = [formatter formatLogMessage:logMessage]; 72 | } 73 | 74 | if (logMsg) 75 | { 76 | const char *msg = [logMsg UTF8String]; 77 | 78 | int aslLogLevel; 79 | switch (logMessage->logFlag) 80 | { 81 | // Note: By default ASL will filter anything above level 5 (Notice). 82 | // So our mappings shouldn't go above that level. 83 | 84 | case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_CRIT; break; 85 | case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_ERR; break; 86 | case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_WARNING; break; 87 | default : aslLogLevel = ASL_LEVEL_NOTICE; break; 88 | } 89 | 90 | asl_log(client, NULL, aslLogLevel, "%s", msg); 91 | } 92 | } 93 | 94 | - (NSString *)loggerName 95 | { 96 | return @"cocoa.lumberjack.aslLogger"; 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/CLogReport.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLogReport.h 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 12-12-4. 6 | // 7 | // 8 | 9 | #import 10 | #import "ASIFormDataRequest.h" 11 | 12 | @interface CLogReport : NSObject 13 | 14 | 15 | + (id)sharedLogReport; 16 | + (void)setSharedLogReport:(CLogReport *)logReport; 17 | - (void)fire; 18 | - (id)initWithLogsDirectory:(NSString *)logsDirectory; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/CompressingLogFileManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDFileLogger.h" 3 | 4 | 5 | @interface CompressingLogFileManager : DDLogFileManagerDefault 6 | { 7 | BOOL upToDate; 8 | BOOL isCompressing; 9 | } 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/ContextFilterLogFormatter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDLog.h" 3 | 4 | @class ContextFilterLogFormatter; 5 | 6 | /** 7 | * Welcome to Cocoa Lumberjack! 8 | * 9 | * The project page has a wealth of documentation if you have any questions. 10 | * https://github.com/robbiehanson/CocoaLumberjack 11 | * 12 | * If you're new to the project you may wish to read the "Getting Started" page. 13 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted 14 | * 15 | * 16 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist. 17 | * 18 | * A log formatter can be added to any logger to format and/or filter its output. 19 | * You can learn more about log formatters here: 20 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters 21 | * 22 | * You can learn more about logging context's here: 23 | * https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomContext 24 | * 25 | * But here's a quick overview / refresher: 26 | * 27 | * Every log statement has a logging context. 28 | * These come from the underlying logging macros defined in DDLog.h. 29 | * The default logging context is zero. 30 | * You can define multiple logging context's for use in your application. 31 | * For example, logically separate parts of your app each have a different logging context. 32 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context. 33 | **/ 34 | @interface ContextWhitelistFilterLogFormatter : NSObject 35 | 36 | - (id)init; 37 | 38 | - (void)addToWhitelist:(int)loggingContext; 39 | - (void)removeFromWhitelist:(int)loggingContext; 40 | 41 | - (NSArray *)whitelist; 42 | 43 | - (BOOL)isOnWhitelist:(int)loggingContext; 44 | 45 | @end 46 | 47 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 48 | #pragma mark - 49 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 50 | 51 | /** 52 | * This class provides a log formatter that filters log statements from a logging context on the blacklist. 53 | **/ 54 | @interface ContextBlacklistFilterLogFormatter : NSObject 55 | 56 | - (id)init; 57 | 58 | - (void)addToBlacklist:(int)loggingContext; 59 | - (void)removeFromBlacklist:(int)loggingContext; 60 | 61 | - (NSArray *)blacklist; 62 | 63 | - (BOOL)isOnBlacklist:(int)loggingContext; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/VdiskLogDebugFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskLogFormatter.h 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 12-11-30. 6 | // 7 | // 8 | 9 | #import 10 | #import "DDLog.h" 11 | #import "DDFileLogger.h" 12 | 13 | @interface VdiskLogDebugFormatter : NSObject { 14 | 15 | NSDateFormatter *_dateFormatter; 16 | } 17 | 18 | - (id)init; 19 | - (id)initWithDateFormatter:(NSDateFormatter *)dateFormatter; 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/VdiskLogDebugFormatter.m: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskLogFormatter.m 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 12-11-30. 6 | // 7 | // 8 | 9 | #import "VdiskLogDebugFormatter.h" 10 | 11 | @implementation VdiskLogDebugFormatter 12 | 13 | - (id)init { 14 | 15 | return [self initWithDateFormatter:nil]; 16 | } 17 | 18 | - (id)initWithDateFormatter:(NSDateFormatter *)aDateFormatter { 19 | 20 | if ((self = [super init])) { 21 | 22 | if (aDateFormatter) { 23 | 24 | _dateFormatter = aDateFormatter; 25 | 26 | } else { 27 | 28 | _dateFormatter = [[NSDateFormatter alloc] init]; 29 | [_dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; 30 | NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 31 | [_dateFormatter setLocale:usLocale]; 32 | [_dateFormatter setDateFormat:@"dd/MMM/yyyy:HH:mm:ss ZZZ"]; 33 | } 34 | } 35 | 36 | return self; 37 | } 38 | 39 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 40 | 41 | NSString *dateAndTime = [_dateFormatter stringFromDate:(logMessage->timestamp)]; 42 | 43 | NSArray *logKeys = @[ 44 | @"create_time", 45 | @"log_ver", 46 | @"appkey", 47 | @"client_ver", 48 | @"client_ver_code", 49 | @"os_and_ver", 50 | @"device", 51 | @"device_uuid", 52 | @"net_env", 53 | @"client_ip", 54 | @"vdisk_uid", 55 | @"sina_uid", 56 | @"http_method_and_url", 57 | @"http_response_status_code", 58 | @"api_error_code", 59 | @"client_error_code", 60 | @"http_bytes_up", 61 | @"http_bytes_down", 62 | @"http_time_request", 63 | @"http_time_response", 64 | @"elapsed", 65 | @"custom_type", 66 | @"custom_key_1", 67 | @"custom_value_1", 68 | @"custom_key_2", 69 | @"custom_value_2", 70 | @"custom_key_3", 71 | @"custom_value_3", 72 | @"custom_key_4", 73 | @"custom_value_4"]; 74 | 75 | NSArray *logArray = [logMessage->logMsg componentsSeparatedByString:@"\t"]; 76 | 77 | NSString *log = [NSString stringWithFormat:@"[%@] : [%@]\n", [logKeys objectAtIndex:0], dateAndTime]; 78 | 79 | int i = 1; 80 | 81 | for (NSString *item in logArray) { 82 | 83 | log = [log stringByAppendingFormat:@"[%@] : %@\n", [logKeys objectAtIndex:i], item]; 84 | i++; 85 | } 86 | 87 | return [NSString stringWithFormat:@"------ [LOG_START] ------\n%@------ [LOG_END] ------", log]; 88 | } 89 | 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/VdiskLogFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskLogFormatter.h 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 12-11-30. 6 | // 7 | // 8 | 9 | #import 10 | #import "DDLog.h" 11 | #import "DDFileLogger.h" 12 | 13 | @interface VdiskLogFormatter : NSObject { 14 | 15 | NSDateFormatter *_dateFormatter; 16 | } 17 | 18 | - (id)init; 19 | - (id)initWithDateFormatter:(NSDateFormatter *)dateFormatter; 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Logs/Extensions/VdiskLogFormatter.m: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskLogFormatter.m 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 12-11-30. 6 | // 7 | // 8 | 9 | #import "VdiskLogFormatter.h" 10 | 11 | @implementation VdiskLogFormatter 12 | 13 | - (id)init { 14 | 15 | return [self initWithDateFormatter:nil]; 16 | } 17 | 18 | - (id)initWithDateFormatter:(NSDateFormatter *)aDateFormatter { 19 | 20 | if ((self = [super init])) { 21 | 22 | if (aDateFormatter) { 23 | 24 | _dateFormatter = aDateFormatter; 25 | 26 | } else { 27 | 28 | _dateFormatter = [[NSDateFormatter alloc] init]; 29 | [_dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; 30 | NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 31 | [_dateFormatter setLocale:usLocale]; 32 | [_dateFormatter setDateFormat:@"dd/MMM/yyyy:HH:mm:ss ZZZ"]; 33 | } 34 | } 35 | 36 | return self; 37 | } 38 | 39 | - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { 40 | 41 | NSString *dateAndTime = [_dateFormatter stringFromDate:(logMessage->timestamp)]; 42 | return [NSString stringWithFormat:@"[%@]\t%@", dateAndTime, logMessage->logMsg]; 43 | } 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskAccountInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import "VdiskQuota.h" 20 | 21 | @interface VdiskAccountInfo : NSObject { 22 | 23 | VdiskQuota *_quota; 24 | NSString *_userId; 25 | NSString *_sinaUserId; 26 | NSDictionary *_original; 27 | 28 | NSString *_screenname; 29 | NSString *_username; 30 | NSURL *_avatarLarge; 31 | NSURL *_avatar; 32 | } 33 | 34 | - (id)initWithDictionary:(NSDictionary *)dict; 35 | 36 | @property (nonatomic, readonly) VdiskQuota *quota; 37 | @property (nonatomic, readonly) NSString *userId; 38 | @property (nonatomic, readonly) NSString *sinaUserId; 39 | 40 | @property (nonatomic, readonly) NSString *screenname; 41 | @property (nonatomic, readonly) NSString *username; 42 | @property (nonatomic, readonly) NSURL *avatarLarge; 43 | @property (nonatomic, readonly) NSURL *avatar; 44 | 45 | 46 | 47 | @end -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskAuthorize.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import 20 | 21 | #import "VdiskRequest.h" 22 | #import "VdiskAuthorizeWebView.h" 23 | 24 | @class VdiskAuthorize; 25 | 26 | @protocol VdiskAuthorizeDelegate 27 | 28 | @required 29 | 30 | - (void)authorize:(VdiskAuthorize *)authorize didSucceedWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken userID:(NSString *)userID expiresIn:(NSInteger)seconds; 31 | - (void)authorize:(VdiskAuthorize *)authorize didFailWithError:(NSError *)error; 32 | - (void)authorizeDidCancel:(VdiskAuthorize *)authorize; 33 | 34 | @end 35 | 36 | @interface VdiskAuthorize : NSObject < 37 | #if TARGET_OS_IPHONE 38 | VdiskAuthorizeWebViewDelegate, 39 | #endif 40 | VdiskRequestDelegate> { 41 | 42 | NSString *_appKey; 43 | NSString *_appSecret; 44 | NSString *_redirectURI; 45 | VdiskRequest *_request; 46 | id _delegate; 47 | NSString *_udid; 48 | } 49 | 50 | @property (nonatomic, retain) NSString *udid;; 51 | @property (nonatomic, retain) NSString *appKey; 52 | @property (nonatomic, retain) NSString *appSecret; 53 | @property (nonatomic, retain) NSString *redirectURI; 54 | @property (nonatomic, retain) VdiskRequest *request; 55 | @property (nonatomic, assign) id delegate; 56 | 57 | - (id)initWithAppKey:(NSString *)appKey appSecret:(NSString *)appSecret udid:(NSString *)udid; 58 | - (void)startAuthorize; 59 | - (void)startAuthorizeUsingUsername:(NSString *)username password:(NSString *)password; 60 | - (void)startAuthorizeUsingRefreshToken:(NSString *)refreshToken; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskAuthorizeWebView.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #if TARGET_OS_IPHONE 20 | 21 | #import 22 | 23 | @class VdiskAuthorizeWebView; 24 | @class VdiskAuthorize; 25 | 26 | @protocol VdiskAuthorizeWebViewDelegate 27 | 28 | - (void)authorizeWebView:(VdiskAuthorizeWebView *)webView didReceiveAuthorizeCode:(NSString *)code; 29 | 30 | @end 31 | 32 | @interface VdiskAuthorizeWebView : UIView { 33 | 34 | UIView *_panelView; 35 | UIView *_containerView; 36 | UIActivityIndicatorView *_indicatorView; 37 | UIWebView *_webView; 38 | UIInterfaceOrientation _previousOrientation; 39 | id _delegate; 40 | UIButton *_closeButton; 41 | } 42 | 43 | @property (nonatomic, assign) id delegate; 44 | @property (nonatomic, assign) VdiskAuthorize *authorize; 45 | 46 | - (void)loadRequestWithURL:(NSURL *)url; 47 | - (void)show:(BOOL)animated; 48 | - (void)hide:(BOOL)animated; 49 | 50 | @end 51 | 52 | #endif -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskDefines.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #define VDISK_FIX_CATEGORY_BUG(name) @interface VDISK_FIX_CATEGORY_BUG##name : NSObject @end @implementation VDISK_FIX_CATEGORY_BUG##name @end 20 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskDeltaEntry.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import "VdiskMetadata.h" 20 | 21 | @interface VdiskDeltaEntry : NSObject { 22 | 23 | NSString *_lowercasePath; 24 | VdiskMetadata *_metadata; 25 | } 26 | 27 | - (id)initWithArray:(NSArray *)array; 28 | 29 | @property (nonatomic, readonly) NSString *lowercasePath; 30 | @property (nonatomic, readonly) VdiskMetadata *metadata; // nil if file has been deleted 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskDeltaEntry.m: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import "VdiskDeltaEntry.h" 20 | 21 | @implementation VdiskDeltaEntry 22 | 23 | @synthesize lowercasePath = _lowercasePath; 24 | @synthesize metadata = _metadata; 25 | 26 | - (id)initWithArray:(NSArray *)array { 27 | 28 | if ((self = [super init])) { 29 | 30 | _lowercasePath = [[array objectAtIndex:0] retain]; 31 | NSObject *maybeMetadata = [array objectAtIndex:1]; 32 | 33 | if (maybeMetadata != [NSNull null]) { 34 | 35 | _metadata = [[VdiskMetadata alloc] initWithDictionary:[array objectAtIndex:1]]; 36 | } 37 | } 38 | 39 | return self; 40 | } 41 | 42 | - (void)dealloc { 43 | 44 | [_lowercasePath release]; 45 | [_metadata release]; 46 | [super dealloc]; 47 | } 48 | 49 | - (BOOL)isEqualToDeltaEntry:(VdiskDeltaEntry *)entry { 50 | 51 | if (self == entry) return YES; 52 | 53 | return (_lowercasePath == entry.lowercasePath || [_lowercasePath isEqual:entry.lowercasePath]) && 54 | (_metadata == entry.metadata || [_metadata isEqual:entry.metadata]); 55 | } 56 | 57 | - (BOOL)isEqual:(id)other { 58 | 59 | if (other == self) return YES; 60 | 61 | if (!other || ![other isKindOfClass:[self class]]) return NO; 62 | 63 | return [self isEqualToDeltaEntry:other]; 64 | } 65 | 66 | 67 | #pragma mark NSCoding methods 68 | 69 | - (id)initWithCoder:(NSCoder*)coder { 70 | 71 | if ((self = [super init])) { 72 | 73 | _lowercasePath = [[coder decodeObjectForKey:@"lowercasePath"] retain]; 74 | _metadata = [[coder decodeObjectForKey:@"metadata"] retain]; 75 | } 76 | 77 | return self; 78 | } 79 | 80 | - (void)encodeWithCoder:(NSCoder*)coder { 81 | 82 | [coder encodeObject:_lowercasePath forKey:@"lowercasePath"]; 83 | [coder encodeObject:_metadata forKey:@"metadata"]; 84 | } 85 | 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskError.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | /* This file contains error codes and the Vdisk error domain */ 20 | 21 | extern NSString *kVdiskErrorDomain; 22 | 23 | // Error codes in the vdisk.weibo.com domain represent the HTTP status code if less than 1000 24 | typedef enum { 25 | 26 | kVdiskErrorNone = 0, 27 | kVdiskErrorGenericError = 1000, 28 | kVdiskErrorFileNotFound = 1001, 29 | kVdiskErrorInsufficientDiskSpace = 1002, 30 | kVdiskErrorIllegalFileType = 1003, // Error sent if you try to upload a directory 31 | kVdiskErrorInvalidResponse = 1004, // Sent when the client does not get valid JSON when it's expecting it, 或者json解析成功了,但是返回内容和文档不一致,或者缺少对应的字段 32 | kVdiskErrorSessionError = 1005, 33 | kVdiskErrorFileContentLengthNotMatch = 1006, // 下载文件的大小和http响应头Content-Length不一致 34 | kVdiskErrorGetFileAttributesFailure = 1007, // 获得文件属性失败 35 | kVdiskErrorS3URLExpired = 1008, // S3下载链接过期 36 | kVdiskErrorMd5NotMatched = 1009, // 大文件分片上传一段文件后,服务器返回的该段文件md5和本地该段文件md5不匹配 37 | 38 | } kVdiskErrorCode; 39 | 40 | 41 | 42 | typedef enum { 43 | 44 | kVdiskErrorLevelUnknown = 0, 45 | kVdiskErrorLevelNetwork = 10, 46 | kVdiskErrorLevelHTTP = 100, 47 | kVdiskErrorLevelLocal = 1000, 48 | kVdiskErrorLevelAPI = 10000, 49 | 50 | } kVdiskErrorLevel; 51 | 52 | 53 | kVdiskErrorLevel VdiskErrorParseErrorLevel(NSError *error); 54 | NSUInteger VdiskErrorParseErrorCode(NSError *error); 55 | NSString *VdiskErrorMessageWithCode(NSError *error); 56 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskLog.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import 20 | 21 | #if !defined(NS_FORMAT_FUNCTION) 22 | #define NS_FORMAT_FUNCTION(F, A) 23 | #endif 24 | 25 | typedef enum { 26 | 27 | kVdiskLogLevelInfo = 0, 28 | kVdiskLogLevelAnalytics, 29 | kVdiskLogLevelWarning, 30 | kVdiskLogLevelError, 31 | kVdiskLogLevelFatal 32 | 33 | } kVdiskLogLevel; 34 | 35 | typedef void VdiskLogCallback(kVdiskLogLevel logLevel, NSString *format, va_list args); 36 | 37 | NSString *VdiskLogFilePath(void); 38 | void VdiskSetupLogToFile(void); 39 | 40 | NSString *VdiskStringFromLogLevel(kVdiskLogLevel logLevel); 41 | 42 | 43 | void VdiskLogSetLevel(kVdiskLogLevel logLevel); 44 | void VdiskLogSetCallback(VdiskLogCallback *callback); 45 | 46 | void VdiskLog(kVdiskLogLevel logLevel, NSString *format, ...) NS_FORMAT_FUNCTION(2,3); 47 | void VdiskLogInfo(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); 48 | void VdiskLogWarning(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); 49 | void VdiskLogError(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); 50 | void VdiskLogFatal(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskQuota.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | @interface VdiskQuota : NSObject { 20 | 21 | unsigned long long _consumedBytes; 22 | unsigned long long _totalBytes; 23 | } 24 | 25 | - (id)initWithDictionary:(NSDictionary *)dict; 26 | 27 | @property (nonatomic, readonly) unsigned long long consumedBytes; 28 | @property (nonatomic, readonly) unsigned long long totalBytes; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskQuota.m: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import "VdiskQuota.h" 20 | 21 | @implementation VdiskQuota 22 | 23 | @synthesize consumedBytes = _consumedBytes; 24 | @synthesize totalBytes = _totalBytes; 25 | 26 | 27 | - (id)initWithDictionary:(NSDictionary *)dict { 28 | 29 | if ((self = [super init])) { 30 | 31 | _consumedBytes = [[dict objectForKey:@"consumed"] longLongValue]; 32 | _totalBytes = [[dict objectForKey:@"quota"] longLongValue]; 33 | } 34 | 35 | return self; 36 | } 37 | 38 | - (void)dealloc { 39 | 40 | [super dealloc]; 41 | } 42 | 43 | #pragma mark NSCoding methods 44 | 45 | - (void)encodeWithCoder:(NSCoder *)coder { 46 | 47 | [coder encodeInt64:_consumedBytes forKey:@"consumedBytes"]; 48 | [coder encodeInt64:_totalBytes forKey:@"totalBytes"]; 49 | } 50 | 51 | - (id)initWithCoder:(NSCoder *)coder { 52 | 53 | self = [super init]; 54 | 55 | _consumedBytes = [coder decodeInt64ForKey:@"consumedBytes"]; 56 | _totalBytes = [coder decodeInt64ForKey:@"totalBytes"]; 57 | 58 | return self; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import 20 | #import "ASIFormDataRequest.h" 21 | 22 | 23 | @protocol VdiskRequestDelegate; 24 | 25 | @interface VdiskRequest : NSObject { 26 | 27 | } 28 | 29 | @property (nonatomic, retain) NSString *url; 30 | @property (nonatomic, retain) NSString *httpMethod; 31 | @property (nonatomic, retain) NSDictionary *params; 32 | @property (nonatomic, retain) NSDictionary *httpHeaderFields; 33 | @property (nonatomic, assign) id delegate; 34 | @property (nonatomic, retain) ASIFormDataRequest *request; 35 | @property (nonatomic, retain) NSMutableData *responseData; 36 | @property (nonatomic, retain) NSString *udid; 37 | 38 | + (VdiskRequest *)requestWithURL:(NSString *)url 39 | httpMethod:(NSString *)httpMethod 40 | params:(NSDictionary *)params 41 | httpHeaderFields:(NSDictionary *)httpHeaderFields 42 | udid:(NSString *)udid 43 | delegate:(id)delegate; 44 | 45 | + (VdiskRequest *)requestWithAccessToken:(NSString *)accessToken 46 | url:(NSString *)url 47 | httpMethod:(NSString *)httpMethod 48 | params:(NSDictionary *)params 49 | httpHeaderFields:(NSDictionary *)httpHeaderFields 50 | udid:(NSString *)udid 51 | delegate:(id)delegate; 52 | 53 | + (NSString *)serializeURL:(NSString *)baseURL params:(NSDictionary *)params httpMethod:(NSString *)httpMethod; 54 | + (NSString *)stringFromDictionary:(NSDictionary *)dict; 55 | 56 | - (void)connect; 57 | - (void)disconnect; 58 | - (void)start; 59 | - (void)cancel; 60 | 61 | - (NSUInteger)responseDataLength; 62 | - (ASIFormDataRequest *)finalRequest; 63 | 64 | 65 | @end 66 | 67 | 68 | 69 | 70 | #pragma mark - 71 | #pragma mark - VdiskRequestDelegate 72 | 73 | @protocol VdiskRequestDelegate 74 | 75 | 76 | @optional 77 | 78 | - (void)request:(VdiskRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders; 79 | 80 | - (void)request:(VdiskRequest *)request didReceiveRawData:(NSData *)data; 81 | 82 | - (void)request:(VdiskRequest *)request didFailWithError:(NSError *)error; 83 | 84 | - (void)request:(VdiskRequest *)request didFinishLoadingWithResult:(id)result; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskSDK-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'VdiskSDK' target in the 'VdiskSDK' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | 9 | #if TARGET_OS_IPHONE 10 | #import 11 | #endif 12 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import "VdiskJSON.h" 20 | #import "VdiskRequest.h" 21 | #import "VdiskAuthorize.h" 22 | #import "VdiskKeychain.h" 23 | #import "VdiskSDKGlobal.h" 24 | #import "VdiskUtil.h" 25 | #import "VdiskComplexRequest.h" 26 | #import "VdiskComplexUpload.h" 27 | #import "VdiskAccountInfo.h" 28 | #import "VdiskError.h" 29 | #import "VdiskDeltaEntry.h" 30 | #import "VdiskLog.h" 31 | #import "VdiskMetadata.h" 32 | #import "VdiskBase64.h" 33 | #import "VdiskQuota.h" 34 | #import "VdiskAuthorizeWebView.h" 35 | #import "VdiskRestClient.h" 36 | #import "VdiskSession.h" 37 | #import "VdiskDeltaEntry.h" 38 | #import "VdiskSharesMetadata.h" 39 | #import "DDLog.h" 40 | #import "CLog.h" 41 | #import "CLogReport.h" 42 | #import "SinaWeibo.h" 43 | #import "SinaWeiboRequest.h" 44 | #import "VdiskSharesCategory.h" 45 | #import "UIDevice-Hardware.h" 46 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskSharesCategory.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSharesCategory.h 3 | // VdiskSDK 4 | // 5 | // Created by Bruce on 13-1-15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface VdiskSharesCategory : NSObject { 12 | 13 | NSString *_categoryId; 14 | NSString *_categoryName; 15 | NSString *_categoryPid; 16 | } 17 | 18 | @property (nonatomic, readonly) NSString *categoryId; 19 | @property (nonatomic, readonly) NSString *categoryName; 20 | @property (nonatomic, readonly) NSString *categoryPid; 21 | 22 | - (id)initWithDictionary:(NSDictionary *)dict; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskSharesCategory.m: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSharesCategory.m 3 | // VdiskSDK 4 | // 5 | // Created by Bruce on 13-1-15. 6 | // 7 | // 8 | 9 | #import "VdiskSharesCategory.h" 10 | 11 | @implementation VdiskSharesCategory 12 | 13 | @synthesize categoryId = _categoryId; 14 | @synthesize categoryName = _categoryName; 15 | @synthesize categoryPid = _categoryPid; 16 | 17 | 18 | - (id)initWithDictionary:(NSDictionary *)dict { 19 | 20 | if ((self = [super init])) { 21 | 22 | _categoryId = [[dict objectForKey:@"category_id"] retain]; 23 | _categoryName = [[dict objectForKey:@"category_name"] retain]; 24 | _categoryPid = [[dict objectForKey:@"category_pid"] retain]; 25 | 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (void)dealloc { 32 | 33 | [_categoryName release]; 34 | [_categoryId release]; 35 | [_categoryPid release]; 36 | 37 | [super dealloc]; 38 | } 39 | 40 | #pragma mark NSCoding methods 41 | 42 | - (id)initWithCoder:(NSCoder *)coder { 43 | 44 | if ((self = [super init])) { 45 | 46 | _categoryId = [[coder decodeObjectForKey:@"categoryId"] retain]; 47 | _categoryName = [[coder decodeObjectForKey:@"categoryName"] retain]; 48 | _categoryPid = [[coder decodeObjectForKey:@"categoryPid"] retain]; 49 | } 50 | 51 | return self; 52 | } 53 | 54 | - (void)encodeWithCoder:(NSCoder *)coder { 55 | 56 | [coder encodeObject:_categoryId forKey:@"categoryId"]; 57 | [coder encodeObject:_categoryName forKey:@"categoryName"]; 58 | [coder encodeObject:_categoryPid forKey:@"categoryPid"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskSharesMetadata.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSharesMetadata.h 3 | // VdiskSDK 4 | // 5 | // Created by Bruce on 12-12-20. 6 | // 7 | // 8 | 9 | #import 10 | #import "VdiskMetadata.h" 11 | 12 | typedef enum { 13 | 14 | kVdiskSharesMetadataTypePublic = 0, 15 | kVdiskSharesMetadataTypeFromFriend, 16 | kVdiskSharesMetadataTypeLinkcommon, 17 | 18 | } kVdiskSharesMetadataType; 19 | 20 | 21 | @interface VdiskSharesMetadata : VdiskMetadata { 22 | 23 | NSString *_appKey; 24 | NSString *_uid; 25 | NSString *_sinaUid; 26 | NSString *_name; 27 | NSString *_cpRef; 28 | NSString *_link; 29 | NSString *_url; 30 | NSDate *_shareTime; 31 | 32 | NSString *_countBrowse; 33 | NSString *_countDownload; 34 | NSString *_countCopy; 35 | NSString *_countLike; 36 | 37 | BOOL _webHot; 38 | BOOL _iosHot; 39 | BOOL _androidHot; 40 | BOOL _isPreview; 41 | BOOL _isStream; 42 | 43 | NSString *_categoryId; 44 | NSString *_shareId; 45 | NSString *_title; 46 | NSString *_descriptions; 47 | NSString *_shareType; 48 | NSString *_nick; 49 | NSString *_price; 50 | NSString *_degree; 51 | NSString *_shareAuth; 52 | NSString *_thumbnail; 53 | 54 | int _sharesMetadataType; 55 | 56 | NSString *_accessCode; 57 | } 58 | 59 | @property (nonatomic, readonly) NSString *appKey; 60 | @property (nonatomic, readonly) NSString *uid; 61 | @property (nonatomic, readonly) NSString *sinaUid; 62 | @property (nonatomic, readonly) NSString *name; 63 | @property (nonatomic, readonly) NSString *cpRef; 64 | @property (nonatomic, readonly) NSString *link; 65 | @property (nonatomic, readonly) NSString *url; 66 | @property (nonatomic, readonly) NSDate *shareTime; 67 | 68 | @property (nonatomic, readonly) NSString *countBrowse; 69 | @property (nonatomic, readonly) NSString *countDownload; 70 | @property (nonatomic, readonly) NSString *countCopy; 71 | @property (nonatomic, readonly) NSString *countLike; 72 | 73 | @property (nonatomic, readonly) BOOL webHot; 74 | @property (nonatomic, readonly) BOOL iosHot; 75 | @property (nonatomic, readonly) BOOL androidHot; 76 | @property (nonatomic, readonly) BOOL isPreview; 77 | @property (nonatomic, readonly) BOOL isStream; 78 | 79 | @property (nonatomic, readonly) NSString *categoryId; 80 | @property (nonatomic, readonly) NSString *shareId; 81 | @property (nonatomic, readonly) NSString *title; 82 | @property (nonatomic, readonly) NSString *descriptions; 83 | @property (nonatomic, readonly) NSString *shareType; 84 | @property (nonatomic, readonly) NSString *nick; 85 | @property (nonatomic, readonly) NSString *price; 86 | @property (nonatomic, readonly) NSString *degree; 87 | @property (nonatomic, readonly) NSString *shareAuth; 88 | @property (nonatomic, readonly) NSString *thumbnail; 89 | 90 | @property (nonatomic, assign) int sharesMetadataType; 91 | 92 | @property (nonatomic, readonly) NSString *accessCode; 93 | 94 | - (id)initWithDictionary:(NSDictionary *)dict sharesMetadataType:(kVdiskSharesMetadataType)sharesMetadataType; 95 | - (id)initWithDictionary:(NSDictionary *)dict sharesMetadataType:(kVdiskSharesMetadataType)sharesMetadataType accessCode:(NSString *)accessCode; 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/VdiskUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // VdiskSDK 3 | // Based on OAuth 2.0 4 | // 5 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 6 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 7 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 8 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 9 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 11 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 12 | // OTHER DEALINGS IN THE SOFTWARE. 13 | // 14 | // Created by Bruce Chen (weibo: @一个开发者) on 12-6-15. 15 | // 16 | // Copyright (c) 2012 Sina Vdisk. All rights reserved. 17 | // 18 | 19 | #import 20 | 21 | //Functions for Encoding Data. 22 | @interface NSData (VdiskEncode) 23 | 24 | - (NSString *)MD5EncodedString; 25 | - (NSString *)SHA1EncodedString; 26 | - (NSData *)HMACSHA1EncodedDataWithKey:(NSString *)key; 27 | - (NSString *)base64EncodedString; 28 | + (NSData *)dataFromBase64String:(NSString *)aString; 29 | 30 | @end 31 | 32 | //Functions for Encoding String. 33 | @interface NSString (VdiskEncode) 34 | 35 | - (NSString *)MD5EncodedString; 36 | - (NSString *)SHA1EncodedString; 37 | - (NSData *)HMACSHA1EncodedDataWithKey:(NSString *)key; 38 | - (NSString *)base64EncodedString; 39 | - (NSString *)URLEncodedString; 40 | - (NSString *)URLEncodedStringWithCFStringEncoding:(CFStringEncoding)encoding; 41 | - (NSString *)stringByDecodingURLFormat; 42 | 43 | @end 44 | 45 | @interface NSString (VdiskUtil) 46 | 47 | + (NSString *)GUIDString; 48 | 49 | @end 50 | 51 | #define FileHashDefaultChunkSizeForReadingData 64 * 1024 52 | 53 | @interface VdiskUtil : NSObject 54 | 55 | + (NSString *)fileMD5HashCreateWithPath:(CFStringRef)filePath ChunkSize:(size_t)chunkSizeForReadingData; 56 | + (NSString *)fileSHA1HashCreateWithPath:(CFStringRef)filePath ChunkSize:(size_t)chunkSizeForReadingData; 57 | + (NSString *)md5WithData:(NSData *)data; 58 | 59 | @end 60 | 61 | 62 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeibo.bundle/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeibo.bundle/images/close.png -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeibo.bundle/images/close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeibo.bundle/images/close@2x.png -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeibo.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinaWeibo.h 3 | // sinaweibo_ios_sdk 4 | // 5 | // Created by Wade Cheng on 4/19/12. 6 | // Copyright (c) 2012 SINA. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SinaWeiboAuthorizeView.h" 11 | #import "SinaWeiboRequest.h" 12 | 13 | @protocol SinaWeiboDelegate; 14 | 15 | @interface SinaWeibo : NSObject 16 | { 17 | NSString *userID; 18 | NSString *accessToken; 19 | NSDate *expirationDate; 20 | id delegate; 21 | 22 | NSString *appKey; 23 | NSString *appSecret; 24 | NSString *appRedirectURI; 25 | NSString *ssoCallbackScheme; 26 | 27 | SinaWeiboRequest *request; 28 | NSMutableSet *requests; 29 | BOOL ssoLoggingIn; 30 | } 31 | 32 | @property (nonatomic, copy) NSString *userID; 33 | @property (nonatomic, copy) NSString *accessToken; 34 | @property (nonatomic, copy) NSDate *expirationDate; 35 | @property (nonatomic, copy) NSString *refreshToken; 36 | @property (nonatomic, copy) NSString *ssoCallbackScheme; 37 | @property (nonatomic, assign) id delegate; 38 | 39 | 40 | - (NSString *)appKey; 41 | - (NSString *)appSecret; 42 | - (NSString *)appRedirectURI; 43 | 44 | 45 | - (id)initWithAppKey:(NSString *)appKey appSecret:(NSString *)appSecrect 46 | appRedirectURI:(NSString *)appRedirectURI 47 | andDelegate:(id)delegate; 48 | 49 | - (id)initWithAppKey:(NSString *)appKey appSecret:(NSString *)appSecrect 50 | appRedirectURI:(NSString *)appRedirectURI 51 | ssoCallbackScheme:(NSString *)ssoCallbackScheme 52 | andDelegate:(id)delegate; 53 | 54 | - (void)applicationDidBecomeActive; 55 | - (BOOL)handleOpenURL:(NSURL *)url; 56 | 57 | // Log in using OAuth Web authorization. 58 | // If succeed, sinaweiboDidLogIn will be called. 59 | - (void)logIn; 60 | 61 | - (void)reLogIn; 62 | 63 | // Log out. 64 | // If succeed, sinaweiboDidLogOut will be called. 65 | - (void)logOut; 66 | 67 | // Check if user has logged in, or the authorization is expired. 68 | - (BOOL)isLoggedIn; 69 | - (BOOL)isAuthorizeExpired; 70 | 71 | 72 | // isLoggedIn && isAuthorizeExpired 73 | - (BOOL)isAuthValid; 74 | 75 | - (SinaWeiboRequest*)requestWithURL:(NSString *)url 76 | params:(NSMutableDictionary *)params 77 | httpMethod:(NSString *)httpMethod 78 | delegate:(id)delegate; 79 | 80 | @end 81 | 82 | 83 | /** 84 | * @description 第三方应用需实现此协议,登录时传入此类对象,用于完成登录结果的回调 85 | */ 86 | @protocol SinaWeiboDelegate 87 | 88 | @optional 89 | 90 | - (void)sinaweiboDidLogIn:(SinaWeibo *)sinaweibo; 91 | - (void)sinaweiboDidLogOut:(SinaWeibo *)sinaweibo; 92 | - (void)sinaweiboLogInDidCancel:(SinaWeibo *)sinaweibo; 93 | - (void)sinaweibo:(SinaWeibo *)sinaweibo logInDidFailWithError:(NSError *)error; 94 | - (void)sinaweibo:(SinaWeibo *)sinaweibo accessTokenInvalidOrExpired:(NSError *)error; 95 | 96 | @end 97 | 98 | extern BOOL SinaWeiboIsDeviceIPad(); 99 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeiboAuthorizeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinaWeiboAuthorizeView.h 3 | // sinaweibo_ios_sdk 4 | // 5 | // Created by Wade Cheng on 4/19/12. 6 | // Copyright (c) 2012 SINA. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol SinaWeiboAuthorizeViewDelegate; 12 | 13 | @interface SinaWeiboAuthorizeView : UIView 14 | { 15 | UIWebView *webView; 16 | UIButton *closeButton; 17 | UIView *modalBackgroundView; 18 | UIActivityIndicatorView *indicatorView; 19 | UIInterfaceOrientation previousOrientation; 20 | 21 | id delegate; 22 | 23 | NSString *appRedirectURI; 24 | NSDictionary *authParams; 25 | } 26 | 27 | @property (nonatomic, assign) id delegate; 28 | 29 | - (id)initWithAuthParams:(NSDictionary *)params 30 | delegate:(id)delegate; 31 | 32 | - (void)show; 33 | - (void)hide; 34 | 35 | @end 36 | 37 | @protocol SinaWeiboAuthorizeViewDelegate 38 | 39 | - (void)authorizeView:(SinaWeiboAuthorizeView *)authView 40 | didRecieveAuthorizationCode:(NSString *)code; 41 | - (void)authorizeView:(SinaWeiboAuthorizeView *)authView 42 | didFailWithErrorInfo:(NSDictionary *)errorInfo; 43 | - (void)authorizeViewDidCancel:(SinaWeiboAuthorizeView *)authView; 44 | 45 | @end -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeiboConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinaWeiboConstants.h 3 | // sinaweibo_ios_sdk 4 | // 5 | // Created by Wade Cheng on 4/22/12. 6 | // Copyright (c) 2012 SINA. All rights reserved. 7 | // 8 | 9 | #ifndef sinaweibo_ios_sdk_SinaWeiboConstants_h 10 | #define sinaweibo_ios_sdk_SinaWeiboConstants_h 11 | 12 | #define SinaWeiboSdkVersion @"2.0" 13 | 14 | #define kSinaWeiboSDKErrorDomain @"SinaWeiboSDKErrorDomain" 15 | #define kSinaWeiboSDKErrorCodeKey @"SinaWeiboSDKErrorCodeKey" 16 | 17 | #define kSinaWeiboSDKAPIDomain @"https://open.weibo.cn/2/" 18 | #define kSinaWeiboSDKOAuth2APIDomain @"https://open.weibo.cn/2/oauth2/" 19 | #define kSinaWeiboWebAuthURL @"https://open.weibo.cn/2/oauth2/authorize" 20 | #define kSinaWeiboWebAccessTokenURL @"https://open.weibo.cn/2/oauth2/access_token" 21 | 22 | #define kSinaWeiboAppAuthURL_iPhone @"sinaweibosso://login" 23 | #define kSinaWeiboAppAuthURL_iPad @"sinaweibohdsso://login" 24 | 25 | typedef enum { 26 | 27 | kSinaWeiboSDKErrorCodeParseError = 1200, 28 | kSinaWeiboSDKErrorCodeSSOParamsError = 1202, 29 | 30 | } SinaWeiboSDKErrorCode; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Classes/VdiskSDK/VdiskSDK/Weibo/SinaWeiboRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinaWeiboRequest.h 3 | // sinaweibo_ios_sdk 4 | // Based on OAuth 2.0 5 | // 6 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 7 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 8 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 9 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 10 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 11 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 12 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 13 | // OTHER DEALINGS IN THE SOFTWARE. 14 | // 15 | // Copyright 2011 Sina. All rights reserved. 16 | // 17 | 18 | #import 19 | 20 | @class SinaWeiboRequest; 21 | @class SinaWeibo; 22 | 23 | 24 | /** 25 | * @description 第三方应用访问微博API时实现此此协议,当sdk完成api的访问后通过传入的此类对象完成接口访问结果的回调,应用在协议实现的相应方法中接收访问结果并做对应处理。 26 | */ 27 | @protocol SinaWeiboRequestDelegate 28 | @optional 29 | - (void)request:(SinaWeiboRequest *)request didReceiveResponse:(NSURLResponse *)response; 30 | - (void)request:(SinaWeiboRequest *)request didReceiveRawData:(NSData *)data; 31 | - (void)request:(SinaWeiboRequest *)request didFailWithError:(NSError *)error; 32 | - (void)request:(SinaWeiboRequest *)request didFinishLoadingWithResult:(id)result; 33 | @end 34 | 35 | @interface SinaWeiboRequest : NSObject 36 | { 37 | SinaWeibo *sinaweibo;//weak reference 38 | 39 | NSString *url; 40 | NSString *httpMethod; 41 | NSDictionary *params; 42 | 43 | NSURLConnection *connection; 44 | NSMutableData *responseData; 45 | 46 | id delegate; 47 | } 48 | 49 | @property (nonatomic, assign) SinaWeibo *sinaweibo; 50 | @property (nonatomic, retain) NSString *url; 51 | @property (nonatomic, retain) NSString *httpMethod; 52 | @property (nonatomic, retain) NSDictionary *params; 53 | @property (nonatomic, assign) id delegate; 54 | 55 | + (SinaWeiboRequest *)requestWithURL:(NSString *)url 56 | httpMethod:(NSString *)httpMethod 57 | params:(NSDictionary *)params 58 | delegate:(id)delegate; 59 | 60 | + (SinaWeiboRequest *)requestWithAccessToken:(NSString *)accessToken 61 | url:(NSString *)url 62 | httpMethod:(NSString *)httpMethod 63 | params:(NSDictionary *)params 64 | delegate:(id)delegate; 65 | 66 | + (NSString *)getParamValueFromUrl:(NSString*)url paramName:(NSString *)paramName; 67 | + (NSString *)serializeURL:(NSString *)baseURL params:(NSDictionary *)params httpMethod:(NSString *)httpMethod; 68 | 69 | - (void)connect; 70 | - (void)disconnect; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Classes/WaveTransMetadata.h: -------------------------------------------------------------------------------- 1 | // 2 | // MetadataReceive.h 3 | // aurioTouch2 4 | // 5 | // Created by Littlebox222 on 13-11-22. 6 | // 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface WaveTransMetadata : NSObject 13 | 14 | @property (nonatomic, retain, readwrite) NSString *code; 15 | @property (nonatomic, retain, readwrite) NSString *sha1; 16 | @property (nonatomic, retain, readwrite) NSString *type; 17 | @property (nonatomic, retain, readwrite) NSDate *ctime; 18 | @property (nonatomic, retain) NSString *content; 19 | @property (nonatomic, readonly) NSString *size; 20 | @property (nonatomic, readwrite) long long totalBytes; 21 | @property (nonatomic, retain, readwrite) NSString *rsCode; 22 | 23 | //file 24 | @property (nonatomic, readonly) NSString *filename; 25 | @property (nonatomic, readonly) NSURL *fileURL; 26 | @property (nonatomic, readonly) NSString *reader; 27 | @property (nonatomic, readonly) BOOL hasCache; 28 | 29 | @property (nonatomic, assign) BOOL uploaded; 30 | @property (nonatomic, readonly) BOOL isJson; 31 | 32 | @property (nonatomic, assign) BOOL isReceived; 33 | 34 | 35 | /* 36 | code 37 | sha1 38 | type 39 | content 40 | size 41 | ctime 42 | */ 43 | 44 | 45 | - (void)setFilename:(NSString *)filename; 46 | 47 | - (id)initWithDictionary:(NSDictionary *)dict; 48 | - (id)initWithDictionary:(NSDictionary *)dict isReceived:(BOOL)isReceived; 49 | 50 | - (id)initWithSha1:(NSString *)sha1 type:(NSString *)type content:(NSString *)content size:(unsigned long long )size filename:(NSString *)filename; 51 | 52 | + (NSString *)humanReadableSize:(unsigned long long)length; 53 | - (NSString *)cachePath:(BOOL)create; 54 | + (NSString *)codeWithSha1:(NSString *)sha1; 55 | 56 | - (void)save; 57 | 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Classes/WaveTransModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // FavoriteModel.h 3 | // VDiskMobile 4 | // 5 | // Created by Bruce on 13-2-4. 6 | // 7 | // 8 | 9 | #import 10 | #import "Database.h" 11 | #import "WaveTransMetadata.h" 12 | 13 | @interface WaveTransModel : NSObject 14 | 15 | 16 | + (NSMutableArray *)metadataList; 17 | + (unsigned long long)insertOrReplaceMetadata:(WaveTransMetadata *)metadata; 18 | + (BOOL)deleteMetadata:(WaveTransMetadata *)metadata; 19 | + (BOOL)existMetadata:(WaveTransMetadata *)metadata; 20 | + (WaveTransMetadata *)metadata:(WaveTransMetadata *)metadata; 21 | + (WaveTransMetadata *)metadataWithCode:(NSString *)code; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Classes/view/AudioCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // AudioCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @interface AudioCell : MainTableViewCell 12 | 13 | @property (nonatomic,retain) IBOutlet UIButton *playAudioBtn; 14 | 15 | @property (nonatomic,retain) UIImageView *bgImageView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Classes/view/BinaryCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | #import "WaveTransMetadata.h" 11 | 12 | @interface BinaryCell :MainTableViewCell // 13 | 14 | @property (nonatomic,retain) IBOutlet UIImageView *bgImageView; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/view/BinaryCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "BinaryCell.h" 10 | 11 | @implementation BinaryCell 12 | 13 | - (id)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | // Initialization code 18 | } 19 | return self; 20 | } 21 | 22 | -(void)setMetadata:(WaveTransMetadata *)metadata 23 | { 24 | [super setMetadata:metadata]; 25 | 26 | // CGFloat offsetX = 0; 27 | // UIColor *statusColor; 28 | // if (metadata.isReceived) { 29 | // offsetX = -4; 30 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 31 | // }else{ 32 | // offsetX = 4; 33 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 34 | // } 35 | // 36 | // UIView *statusView = [self.contentView viewWithTag:999]; 37 | // if (!statusView) { 38 | // statusView = [[[UIView alloc] init] autorelease]; 39 | // statusView.tag = 999; 40 | // [self.contentView addSubview:statusView]; 41 | // 42 | // CALayer *layer = [CALayer layer]; 43 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 44 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 45 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 46 | // layer.shadowRadius = 4.0f; 47 | // layer.shadowOpacity = 0.80f; 48 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 49 | // 50 | // [statusView.layer addSublayer:layer]; 51 | // 52 | // } 53 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 54 | // statusView.backgroundColor = statusColor; 55 | // 56 | // self.bgImageView.frame = CGRectMake(offsetX, 0, self.bounds.size.width, self.bounds.size.height); 57 | 58 | } 59 | 60 | -(void)dealloc{ 61 | self.bgImageView = nil; 62 | 63 | [super dealloc]; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Classes/view/ContactsCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // ContactsCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @class EGOImageView; 12 | 13 | @interface ContactsCell : MainTableViewCell 14 | 15 | @property (nonatomic,retain) IBOutlet EGOImageView *headerImageView; 16 | @property (nonatomic,retain) IBOutlet UILabel *nameLabel; 17 | @property (nonatomic,retain) IBOutlet UILabel *descriptionLabel; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Classes/view/ContactsCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // ContactsCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "ContactsCell.h" 10 | #import "WaveTransMetadata.h" 11 | 12 | #import "VdiskJSON.h" 13 | 14 | @implementation ContactsCell 15 | 16 | - (id)initWithFrame:(CGRect)frame 17 | { 18 | self = [super initWithFrame:frame]; 19 | if (self) { 20 | // Initialization 21 | } 22 | return self; 23 | } 24 | 25 | /* 26 | // Only override drawRect: if you perform custom drawing. 27 | // An empty implementation adversely affects performance during animation. 28 | - (void)drawRect:(CGRect)rect 29 | { 30 | // Drawing code 31 | } 32 | */ 33 | 34 | -(void)setMetadata:(WaveTransMetadata *)metadata 35 | { 36 | super.metadata = metadata; 37 | 38 | // CGFloat offsetX = 0; 39 | // UIColor *statusColor; 40 | // if (metadata.isReceived) { 41 | // offsetX = -4; 42 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 43 | // }else{ 44 | // offsetX = 4; 45 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 46 | // } 47 | // 48 | // UIView *statusView = [self.contentView viewWithTag:999]; 49 | // if (!statusView) { 50 | // statusView = [[[UIView alloc] init] autorelease]; 51 | // statusView.tag = 999; 52 | // [self.contentView addSubview:statusView]; 53 | // 54 | // CALayer *layer = [CALayer layer]; 55 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 56 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 57 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 58 | // layer.shadowRadius = 4.0f; 59 | // layer.shadowOpacity = 0.80f; 60 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 61 | // 62 | // [statusView.layer addSublayer:layer]; 63 | // 64 | // } 65 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 66 | // statusView.backgroundColor = statusColor; 67 | 68 | 69 | NSDictionary *jsonDict = [metadata.content JSONValue]; 70 | self.nameLabel.text = [jsonDict objectForKey:@"name"]; 71 | self.descriptionLabel.text = [jsonDict objectForKey:@"phone"]; 72 | 73 | // self.headerImageView.imageURL = [NSURL URLWithString:[jsonDict objectForKey:@"avatar_large"]]; 74 | } 75 | 76 | -(void)dealloc 77 | { 78 | self.nameLabel = nil; 79 | self.descriptionLabel = nil; 80 | self.headerImageView = nil; 81 | 82 | [super dealloc]; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Classes/view/EGOImageView/EGOCache/EGOCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // EGOCache.h 3 | // enormego 4 | // 5 | // Created by Shaun Harrison on 7/4/09. 6 | // Copyright (c) 2009-2010 enormego 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import 28 | 29 | 30 | @interface EGOCache : NSObject { 31 | @private 32 | NSMutableDictionary* cacheDictionary; 33 | NSOperationQueue* diskOperationQueue; 34 | NSTimeInterval defaultTimeoutInterval; 35 | } 36 | 37 | + (EGOCache*)currentCache; 38 | 39 | - (void)clearCache; 40 | - (void)removeCacheForKey:(NSString*)key; 41 | 42 | - (BOOL)hasCacheForKey:(NSString*)key; 43 | 44 | - (NSData*)dataForKey:(NSString*)key; 45 | - (void)setData:(NSData*)data forKey:(NSString*)key; 46 | - (void)setData:(NSData*)data forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 47 | 48 | - (NSString*)stringForKey:(NSString*)key; 49 | - (void)setString:(NSString*)aString forKey:(NSString*)key; 50 | - (void)setString:(NSString*)aString forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 51 | 52 | #if TARGET_OS_IPHONE 53 | - (UIImage*)imageForKey:(NSString*)key; 54 | - (void)setImage:(UIImage*)anImage forKey:(NSString*)key; 55 | - (void)setImage:(UIImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 56 | #else 57 | - (NSImage*)imageForKey:(NSString*)key; 58 | - (void)setImage:(NSImage*)anImage forKey:(NSString*)key; 59 | - (void)setImage:(NSImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 60 | #endif 61 | 62 | - (NSData*)plistForKey:(NSString*)key; 63 | - (void)setPlist:(id)plistObject forKey:(NSString*)key; 64 | - (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 65 | 66 | - (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key; 67 | - (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; 68 | 69 | @property(nonatomic,assign) NSTimeInterval defaultTimeoutInterval; // Default is 1 day 70 | @end -------------------------------------------------------------------------------- /Classes/view/EGOImageView/EGOImageLoader/EGOImageLoadConnection.h: -------------------------------------------------------------------------------- 1 | // 2 | // EGOImageLoadConnection.h 3 | // EGOImageLoading 4 | // 5 | // Created by Shaun Harrison on 12/1/09. 6 | // Copyright (c) 2009-2010 enormego 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import 28 | 29 | @protocol EGOImageLoadConnectionDelegate; 30 | 31 | @interface EGOImageLoadConnection : NSObject { 32 | @private 33 | NSURL* _imageURL; 34 | NSURLResponse* _response; 35 | NSMutableData* _responseData; 36 | NSURLConnection* _connection; 37 | NSTimeInterval _timeoutInterval; 38 | 39 | id _delegate; 40 | } 41 | 42 | - (id)initWithImageURL:(NSURL*)aURL delegate:(id)delegate; 43 | 44 | - (void)start; 45 | - (void)cancel; 46 | 47 | @property(nonatomic,readonly) NSData* responseData; 48 | @property(nonatomic,readonly,getter=imageURL) NSURL* imageURL; 49 | 50 | @property(nonatomic,retain) NSURLResponse* response; 51 | @property(nonatomic,assign) id delegate; 52 | 53 | @property(nonatomic,assign) NSTimeInterval timeoutInterval; // Default is 30 seconds 54 | 55 | #if __EGOIL_USE_BLOCKS 56 | @property(nonatomic,readonly) NSMutableDictionary* handlers; 57 | #endif 58 | 59 | @end 60 | 61 | @protocol EGOImageLoadConnectionDelegate 62 | - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection; 63 | - (void)imageLoadConnection:(EGOImageLoadConnection *)connection didFailWithError:(NSError *)error; 64 | @end -------------------------------------------------------------------------------- /Classes/view/EGOImageView/EGOImageLoader/EGOImageLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // EGOImageLoader.h 3 | // EGOImageLoading 4 | // 5 | // Created by Shaun Harrison on 9/15/09. 6 | // Copyright (c) 2009-2010 enormego 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import 28 | 29 | #ifndef __EGOIL_USE_BLOCKS 30 | #define __EGOIL_USE_BLOCKS 0 31 | #endif 32 | 33 | #ifndef __EGOIL_USE_NOTIF 34 | #define __EGOIL_USE_NOTIF 1 35 | #endif 36 | 37 | @protocol EGOImageLoaderObserver; 38 | @interface EGOImageLoader : NSObject/**/ { 39 | @private 40 | NSDictionary* _currentConnections; 41 | NSMutableDictionary* currentConnections; 42 | #if __EGOIL_USE_BLOCKS 43 | dispatch_queue_t _operationQueue; 44 | #endif 45 | 46 | NSLock* connectionsLock; 47 | } 48 | 49 | + (EGOImageLoader*)sharedImageLoader; 50 | 51 | - (BOOL)isLoadingImageURL:(NSURL*)aURL; 52 | 53 | #if __EGOIL_USE_NOTIF 54 | - (void)loadImageForURL:(NSURL*)aURL observer:(id)observer; 55 | - (UIImage*)imageForURL:(NSURL*)aURL shouldLoadWithObserver:(id)observer; 56 | 57 | - (void)removeObserver:(id)observer; 58 | - (void)removeObserver:(id)observer forURL:(NSURL*)aURL; 59 | #endif 60 | 61 | #if __EGOIL_USE_BLOCKS 62 | - (void)loadImageForURL:(NSURL*)aURL completion:(void (^)(UIImage* image, NSURL* imageURL, NSError* error))completion; 63 | - (void)loadImageForURL:(NSURL*)aURL style:(NSString*)style styler:(UIImage* (^)(UIImage* image))styler completion:(void (^)(UIImage* image, NSURL* imageURL, NSError* error))completion; 64 | #endif 65 | 66 | - (BOOL)hasLoadedImageURL:(NSURL*)aURL; 67 | - (void)cancelLoadForURL:(NSURL*)aURL; 68 | 69 | - (void)clearCacheForURL:(NSURL*)aURL; 70 | - (void)clearCacheForURL:(NSURL*)aURL style:(NSString*)style; 71 | 72 | @property(nonatomic,retain) NSDictionary* currentConnections; 73 | @end 74 | 75 | @protocol EGOImageLoaderObserver 76 | @optional 77 | - (void)imageLoaderDidLoad:(NSNotification*)notification; // Object will be EGOImageLoader, userInfo will contain imageURL and image 78 | - (void)imageLoaderDidFailToLoad:(NSNotification*)notification; // Object will be EGOImageLoader, userInfo will contain error 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/view/EGOImageView/EGOImageView/EGOImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // EGOImageView.h 3 | // EGOImageLoading 4 | // 5 | // Created by Shaun Harrison on 9/15/09. 6 | // Copyright (c) 2009-2010 enormego 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | // 26 | 27 | #import 28 | #import "EGOImageLoader.h" 29 | 30 | @protocol EGOImageViewDelegate; 31 | @interface EGOImageView : UIImageView { 32 | @private 33 | NSURL* imageURL; 34 | UIImage* placeholderImage; 35 | id delegate; 36 | 37 | } 38 | 39 | - (id)initWithPlaceholderImage:(UIImage*)anImage; // delegate:nil 40 | - (id)initWithPlaceholderImage:(UIImage*)anImage delegate:(id)aDelegate; 41 | 42 | - (void)cancelImageLoad; 43 | 44 | 45 | @property (nonatomic,retain) NSTimer *mNSTimer; 46 | @property(assign) BOOL needPlayAnim; 47 | 48 | @property(nonatomic,retain) NSURL* imageURL; 49 | @property(nonatomic,retain) UIImage* placeholderImage; 50 | @property(nonatomic,assign) id delegate; 51 | @property (nonatomic,assign)CGSize rectSize; 52 | @end 53 | 54 | @protocol EGOImageViewDelegate 55 | @optional 56 | - (void)imageViewLoadedImage:(EGOImageView*)imageView; 57 | - (void)imageViewFailedToLoadImage:(EGOImageView*)imageView error:(NSError*)error; 58 | @end -------------------------------------------------------------------------------- /Classes/view/EGOImageView/UIImage+UIImageScale.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+UIImageScale.h 3 | // Color 4 | // 5 | // Created by chao han on 12-5-23. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (UIImageScale) 12 | 13 | -(UIImage*)getSubImage:(CGRect)rect; 14 | -(UIImage*)scaleToSize:(CGSize)size; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/view/EGOImageView/UIImage+UIImageScale.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+UIImageScale.m 3 | // Color 4 | // 5 | // Created by chao han on 12-5-23. 6 | // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+UIImageScale.h" 10 | 11 | 12 | @implementation UIImage (UIImageScale) 13 | 14 | 15 | -(UIImage*)getSubImage:(CGRect)rect 16 | { 17 | CGImageRef subImageRef = CGImageCreateWithImageInRect(self.CGImage, rect); 18 | CGRect smallBounds = CGRectMake(0, 0, CGImageGetWidth(subImageRef), CGImageGetHeight(subImageRef)); 19 | 20 | UIGraphicsBeginImageContext(smallBounds.size); 21 | CGContextRef context = UIGraphicsGetCurrentContext(); 22 | CGContextDrawImage(context, smallBounds, subImageRef); 23 | UIImage* smallImage = [UIImage imageWithCGImage:subImageRef]; 24 | if (subImageRef != NULL) { 25 | CFRelease(subImageRef); 26 | } 27 | UIGraphicsEndImageContext(); 28 | 29 | return smallImage; 30 | } 31 | 32 | 33 | -(UIImage*)scaleToSize:(CGSize)size 34 | { 35 | CGFloat width = CGImageGetWidth(self.CGImage); 36 | CGFloat height = CGImageGetHeight(self.CGImage); 37 | 38 | if (!(self.imageOrientation == UIImageOrientationUp || self.imageOrientation == UIImageOrientationDown)){ 39 | 40 | width = CGImageGetHeight(self.CGImage); 41 | height = CGImageGetWidth(self.CGImage); 42 | } 43 | 44 | float radio = 1; 45 | 46 | if (size.width > size.height) { 47 | radio = size.width *1.0 / width; 48 | }else{ 49 | radio = size.height *1.0 / height; 50 | } 51 | 52 | width = width*radio; 53 | height = height*radio; 54 | 55 | /* 56 | int xPos = (size.width - width)/2; 57 | int yPos = (size.height-height)/2; 58 | */ 59 | 60 | 61 | UIGraphicsBeginImageContext(CGSizeMake(width, height)); 62 | 63 | 64 | [self drawInRect:CGRectMake(0, 0, width, height)]; 65 | 66 | 67 | UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); 68 | 69 | 70 | UIGraphicsEndImageContext(); 71 | 72 | 73 | return scaledImage; 74 | } 75 | 76 | 77 | 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/view/MSCMoreOptionTableViewCell/MSCMoreOptionTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MSCMoreOptionTableViewCell.h 3 | // MSCMoreOptionTableViewCell 4 | // 5 | // Created by Manfred Scheiner (@scheinem) on 20.08.13. 6 | // Copyright (c) 2013 Manfred Scheiner (@scheinem). All rights reserved. 7 | // 8 | 9 | @protocol MSCMoreOptionTableViewCellDelegate 10 | 11 | @required 12 | - (void)tableView:(UITableView *)tableView moreOptionButtonPressedInRowAtIndexPath:(NSIndexPath *)indexPath; 13 | 14 | @optional 15 | 16 | // "More button" 17 | 18 | /* 19 | * If not implemented, returning nil or an empty string the "More" button will have 20 | * no title and it's width will be 60 points. 21 | */ 22 | - (NSString *)tableView:(UITableView *)tableView titleForMoreOptionButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 23 | 24 | /* 25 | * If not implemented or returning nil the "More" button will have [UIColor whiteColor] 26 | * as titleColor; 27 | */ 28 | - (UIColor *)tableView:(UITableView *)tableView titleColorForMoreOptionButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 29 | 30 | /* 31 | * If not implemented or returning nil the "More" button will have [UIColor lightGrayColor] 32 | * as backgroundColor; 33 | */ 34 | - (UIColor *)tableView:(UITableView *)tableView backgroundColorForMoreOptionButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 35 | 36 | // "Delete button" 37 | 38 | /* 39 | * If not implemented or returning nil the "Delete" button will have the default backgroundColor; 40 | */ 41 | - (UIColor *)tableView:(UITableView *)tableView backgroundColorForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 42 | 43 | /* 44 | * If not implemented or returning nil the "Delete" button will have the default titleColor; 45 | */ 46 | - (UIColor *)tableView:(UITableView *)tableView titleColorForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath; 47 | 48 | @end 49 | 50 | @interface MSCMoreOptionTableViewCell : UITableViewCell 51 | 52 | @property (nonatomic, weak) id delegate; 53 | 54 | @end 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Classes/view/MainTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainTableViewCell.h 3 | // SoundTransform 4 | // 5 | // Created by hanchao on 13-11-22. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "MSCMoreOptionTableViewCell.h" 12 | 13 | #import "MainViewController.h" 14 | 15 | #define RECEIVED_VIEW_COLOR [UIColor colorWithRed:0.18f green:0.67f blue:0.84f alpha:1.0f] 16 | #define CREATED_VIEW_COLOR [UIColor colorWithRed:30/255.0f green:252/255.0f blue:192/255.0f alpha:1.0f] 17 | 18 | @class WaveTransMetadata; 19 | 20 | //@protocol MainTableViewCellProtocol 21 | // 22 | //@required 23 | //-(void)setMetadata:(WaveTransMetadata *)metadata; 24 | // 25 | //@end 26 | 27 | @interface MainTableViewCell : MSCMoreOptionTableViewCell 28 | 29 | @property (nonatomic,retain) WaveTransMetadata *metadata; 30 | 31 | @property (nonatomic,assign) CGFloat downloadProgress; 32 | 33 | @property (nonatomic,retain) IBOutlet UILabel *fileNameLabel; 34 | @property (nonatomic,retain) IBOutlet UILabel *createDateLabel; 35 | @property (nonatomic,retain) IBOutlet UIButton *sendBeepBtn; 36 | @property (nonatomic,retain) IBOutlet UILabel *receiveState; 37 | 38 | @property (nonatomic,retain) IBOutlet UIView *sepraterView; 39 | @property (nonatomic,retain) IBOutlet UIView *progressView; 40 | 41 | @end 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Classes/view/PhotoCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @class EGOImageView; 12 | 13 | @interface PhotoCell : MainTableViewCell 14 | 15 | 16 | @property (nonatomic,retain) IBOutlet EGOImageView *photoImageView; 17 | @end 18 | -------------------------------------------------------------------------------- /Classes/view/PhotoCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "PhotoCell.h" 10 | #import "EGOImageView.h" 11 | #import "WaveTransMetadata.h" 12 | 13 | @implementation PhotoCell 14 | 15 | - (id)initWithFrame:(CGRect)frame 16 | { 17 | self = [super initWithFrame:frame]; 18 | if (self) { 19 | // Initialization code 20 | } 21 | return self; 22 | } 23 | 24 | /* 25 | // Only override drawRect: if you perform custom drawing. 26 | // An empty implementation adversely affects performance during animation. 27 | - (void)drawRect:(CGRect)rect 28 | { 29 | // Drawing code 30 | } 31 | */ 32 | 33 | -(void)awakeFromNib 34 | { 35 | [super awakeFromNib]; 36 | self.photoImageView.clipsToBounds = YES; 37 | } 38 | 39 | -(void)setMetadata:(WaveTransMetadata *)metadata 40 | { 41 | // CGFloat offsetX = 0; 42 | // UIColor *statusColor; 43 | // if (metadata.isReceived) { 44 | // offsetX = -4; 45 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 46 | // }else{ 47 | // offsetX = 4; 48 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 49 | // } 50 | // 51 | // UIView *statusView = [self.contentView viewWithTag:999]; 52 | // if (!statusView) { 53 | // statusView = [[[UIView alloc] init] autorelease]; 54 | // statusView.tag = 999; 55 | // [self.contentView addSubview:statusView]; 56 | // 57 | // CALayer *layer = [CALayer layer]; 58 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 59 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 60 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 61 | // layer.shadowRadius = 4.0f; 62 | // layer.shadowOpacity = 0.80f; 63 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 64 | // 65 | // [statusView.layer addSublayer:layer]; 66 | // 67 | // } 68 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 69 | // statusView.backgroundColor = statusColor; 70 | // 71 | // self.photoImageView.frame = CGRectMake(offsetX, 0, self.bounds.size.width, self.bounds.size.height); 72 | 73 | super.metadata = metadata; 74 | 75 | if (super.metadata.fileURL!= nil && [super.metadata.fileURL.absoluteString hasPrefix:@"http://"]) { 76 | [self.photoImageView setImageURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://vdisk-thumb-1.wcdn.cn/frame.640x480/%@",[super.metadata.fileURL.absoluteString substringFromIndex:7]]]];// 77 | }else if([super.metadata hasCache]){ 78 | [self.photoImageView setImageURL:[NSURL fileURLWithPath:[super.metadata cachePath:NO]]]; 79 | 80 | } 81 | } 82 | 83 | -(void)dealloc 84 | { 85 | self.photoImageView = nil; 86 | 87 | [super dealloc]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Classes/view/PureTextCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // PureTextCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @interface PureTextCell : MainTableViewCell 12 | 13 | @property (nonatomic,retain) IBOutlet UILabel *pureTextLabel; 14 | @property (nonatomic,retain) IBOutlet UIView *pureTextParentView; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/view/PureTextCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // PureTextCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "PureTextCell.h" 10 | 11 | #import "WaveTransMetadata.h" 12 | 13 | @implementation PureTextCell 14 | 15 | - (id)initWithFrame:(CGRect)frame 16 | { 17 | self = [super initWithFrame:frame]; 18 | if (self) { 19 | // Initialization code 20 | } 21 | return self; 22 | } 23 | 24 | -(void)awakeFromNib 25 | { 26 | [super awakeFromNib]; 27 | self.pureTextParentView.layer.cornerRadius = 4.0f; 28 | } 29 | 30 | /* 31 | // Only override drawRect: if you perform custom drawing. 32 | // An empty implementation adversely affects performance during animation. 33 | - (void)drawRect:(CGRect)rect 34 | { 35 | // Drawing code 36 | } 37 | */ 38 | 39 | -(void)setMetadata:(WaveTransMetadata *)metadata 40 | { 41 | // CGFloat offsetX = 0; 42 | // UIColor *statusColor; 43 | // if (metadata.isReceived) { 44 | // offsetX = -4; 45 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 46 | // }else{ 47 | // offsetX = 4; 48 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 49 | // } 50 | // 51 | // UIView *statusView = [self.contentView viewWithTag:999]; 52 | // if (!statusView) { 53 | // statusView = [[[UIView alloc] init] autorelease]; 54 | // statusView.tag = 999; 55 | //// [self.contentView addSubview:statusView]; 56 | // [self.contentView insertSubview:statusView belowSubview:self.sepraterView]; 57 | // 58 | // CALayer *layer = [CALayer layer]; 59 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 60 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 61 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 62 | // layer.shadowRadius = 4.0f; 63 | // layer.shadowOpacity = 0.80f; 64 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 65 | // 66 | // [statusView.layer addSublayer:layer]; 67 | // 68 | // } 69 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 70 | // statusView.backgroundColor = statusColor; 71 | 72 | super.metadata = metadata; 73 | 74 | self.pureTextLabel.text = super.metadata.content; 75 | } 76 | 77 | 78 | -(void)dealloc 79 | { 80 | self.pureTextLabel = nil; 81 | self.pureTextParentView = nil; 82 | 83 | [super dealloc]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/view/TableViewCellFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // TablViewCellFactory.h 3 | // SoundTransform 4 | // 5 | // Created by hanchao on 13-11-25. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class MainTableViewCell; 12 | @class WaveTransMetadata; 13 | 14 | typedef NS_ENUM(NSInteger, MetaDataFileType) { 15 | MetaDataFileTypeBinary, //二进制文件 16 | MetaDataFileTypeText, //文本文件 17 | MetaDataFileTypePhoto, //图片 18 | MetaDataFileTypeAudio, //音频 19 | MetaDataFileTypeVideo //视频 20 | 21 | }; 22 | 23 | @interface TableViewCellFactory : NSObject 24 | 25 | +(id)getTableViewCellByCellType:(WaveTransMetadata *)metadataReader 26 | tableView:(UITableView *)tableView 27 | owner:(id)owner; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Classes/view/TableViewCellFactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // TablViewCellFactory.m 3 | // SoundTransform 4 | // 5 | // Created by hanchao on 13-11-25. 6 | // Copyright (c) 2013年 hanchao. All rights reserved. 7 | // 8 | 9 | #import "TableViewCellFactory.h" 10 | #import "MainTableViewCell.h" 11 | #import "BinaryCell.h" 12 | #import "TextCell.h" 13 | #import "PhotoCell.h" 14 | #import "AudioCell.h" 15 | #import "VideoCell.h" 16 | #import "WaveTransMetadata.h" 17 | 18 | #import "VdiskJSON.h" 19 | 20 | @implementation TableViewCellFactory 21 | 22 | +(id)getTableViewCellByCellType:(WaveTransMetadata *)metadata 23 | tableView:(UITableView *)tableView 24 | owner:(id)owner 25 | { 26 | NSString *identifier = nil; 27 | 28 | if ([metadata.type isEqualToString:@"file"]) {//text | url | file 29 | 30 | if ([metadata.reader isEqualToString:@"image"]) { 31 | identifier = @"PhotoCell"; 32 | }else if ([metadata.reader isEqualToString:@"sound"]){ 33 | identifier = @"AudioCell"; 34 | }else if ([metadata.reader isEqualToString:@"video"]){ 35 | identifier = @"VideoCell"; 36 | }else if ([metadata.reader isEqualToString:@"txt"] || [metadata.reader isEqualToString:@"code"]){ 37 | identifier = @"TextCell"; 38 | }else { 39 | identifier = @"BinaryCell"; 40 | } 41 | }else if ([metadata.type isEqualToString:@"url"]){ 42 | //字符串 43 | identifier = @"PureTextCell"; 44 | }else if ([metadata.type isEqualToString:@"text"]){ 45 | 46 | if(metadata.isJson){ 47 | NSDictionary *jsonDict = [metadata.content JSONValue]; 48 | 49 | if ([[jsonDict allKeys] containsObject:@"wave_weibo_card"]) {//weibo 50 | 51 | identifier = @"WeiboCell"; 52 | 53 | }else if ([[jsonDict allKeys] containsObject:@"wave_people_card"]) {//weibo 54 | 55 | identifier = @"ContactsCell"; 56 | }else{ 57 | //TODO:其他 58 | identifier = @"PureTextCell"; 59 | } 60 | }else{ 61 | //字符串 62 | identifier = @"PureTextCell"; 63 | 64 | } 65 | 66 | }else{ 67 | //TODO:unknow type!!! 68 | } 69 | 70 | if (identifier) { 71 | 72 | MainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 73 | 74 | if (!cell) { 75 | cell = [[[NSBundle mainBundle] loadNibNamed:identifier owner:owner options:nil] 76 | objectAtIndex:0]; 77 | } 78 | 79 | cell.delegate = owner; 80 | 81 | cell.metadata = metadata; 82 | // //TODO:test 83 | // cell.downloadProgress = 0.74f; 84 | 85 | return cell; 86 | } 87 | 88 | return nil; 89 | 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /Classes/view/TextCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @interface TextCell : MainTableViewCell 12 | @property (nonatomic,retain) IBOutlet UIImageView *bgImageView; 13 | @end 14 | -------------------------------------------------------------------------------- /Classes/view/TextCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // TextCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "TextCell.h" 10 | #import "WaveTransMetadata.h" 11 | 12 | @implementation TextCell 13 | 14 | - (id)initWithFrame:(CGRect)frame 15 | { 16 | self = [super initWithFrame:frame]; 17 | if (self) { 18 | // Initialization code 19 | } 20 | return self; 21 | } 22 | 23 | /* 24 | // Only override drawRect: if you perform custom drawing. 25 | // An empty implementation adversely affects performance during animation. 26 | - (void)drawRect:(CGRect)rect 27 | { 28 | // Drawing code 29 | } 30 | */ 31 | 32 | -(void)setMetadata:(WaveTransMetadata *)metadata 33 | { 34 | [super setMetadata:metadata]; 35 | 36 | // CGFloat offsetX = 0; 37 | // UIColor *statusColor; 38 | // if (metadata.isReceived) { 39 | // offsetX = -4; 40 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 41 | // }else{ 42 | // offsetX = 4; 43 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 44 | // } 45 | // 46 | // UIView *statusView = [self.contentView viewWithTag:999]; 47 | // if (!statusView) { 48 | // statusView = [[[UIView alloc] init] autorelease]; 49 | // statusView.tag = 999; 50 | // [self.contentView addSubview:statusView]; 51 | // [self.contentView bringSubviewToFront:statusView]; 52 | // 53 | // CALayer *layer = [CALayer layer]; 54 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 55 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 56 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 57 | // layer.shadowRadius = 4.0f; 58 | // layer.shadowOpacity = 0.80f; 59 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 60 | // 61 | // [statusView.layer addSublayer:layer]; 62 | // 63 | // } 64 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 65 | // statusView.backgroundColor = statusColor; 66 | // 67 | // self.bgImageView.frame = CGRectMake(offsetX, 0, self.bounds.size.width, self.bounds.size.height); 68 | 69 | } 70 | 71 | -(void)dealloc 72 | { 73 | self.bgImageView = nil; 74 | [super dealloc]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Classes/view/VideoCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | 12 | @class EGOImageView; 13 | @interface VideoCell : MainTableViewCell 14 | 15 | @property (nonatomic,retain) IBOutlet EGOImageView *screenshotImageView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Classes/view/VideoCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "VideoCell.h" 10 | #import 11 | #import "WaveTransMetadata.h" 12 | #import "EGOImageView.h" 13 | 14 | @implementation VideoCell 15 | 16 | - (id)initWithFrame:(CGRect)frame 17 | { 18 | self = [super initWithFrame:frame]; 19 | if (self) { 20 | // Initialization code 21 | } 22 | return self; 23 | } 24 | 25 | -(void)setMetadata:(WaveTransMetadata *)metadata 26 | { 27 | super.metadata = metadata; 28 | 29 | // CGFloat offsetX = 0; 30 | // UIColor *statusColor; 31 | // if (metadata.isReceived) { 32 | // offsetX = -4; 33 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 34 | // }else{ 35 | // offsetX = 4; 36 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 37 | // } 38 | // 39 | // UIView *statusView = [self.contentView viewWithTag:999]; 40 | // if (!statusView) { 41 | // statusView = [[[UIView alloc] init] autorelease]; 42 | // statusView.tag = 999; 43 | // [self.contentView addSubview:statusView]; 44 | // 45 | // CALayer *layer = [CALayer layer]; 46 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 47 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 48 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 49 | // layer.shadowRadius = 4.0f; 50 | // layer.shadowOpacity = 0.80f; 51 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 52 | // 53 | // [statusView.layer addSublayer:layer]; 54 | // 55 | // } 56 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 57 | // statusView.backgroundColor = statusColor; 58 | // 59 | // self.screenshotImageView.frame = CGRectMake(offsetX, 0, self.bounds.size.width, self.bounds.size.height); 60 | 61 | 62 | NSString *screenshotFilePath = [NSString stringWithFormat:@"%@.screenshot",[super.metadata cachePath:NO]]; 63 | 64 | NSFileManager *fm = [NSFileManager defaultManager]; 65 | 66 | if (![fm fileExistsAtPath:screenshotFilePath]) { 67 | 68 | NSURL *mediaUrl = [NSURL fileURLWithPath:[super.metadata cachePath:NO]]; 69 | if (mediaUrl != nil) { 70 | MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaUrl]; 71 | UIImage *image=[mp thumbnailImageAtTime:(NSTimeInterval)1 timeOption:MPMovieTimeOptionNearestKeyFrame]; 72 | [mp stop]; 73 | [mp release]; 74 | 75 | [UIImagePNGRepresentation(image) writeToFile:screenshotFilePath atomically:YES]; 76 | 77 | } 78 | } 79 | 80 | self.screenshotImageView.imageURL = [NSURL fileURLWithPath:screenshotFilePath]; 81 | 82 | } 83 | 84 | -(void)dealloc 85 | { 86 | self.screenshotImageView = nil; 87 | [super dealloc]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Classes/view/WeiboCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeiboCell.h 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "MainTableViewCell.h" 10 | 11 | @class EGOImageView; 12 | 13 | @interface WeiboCell : MainTableViewCell 14 | 15 | @property (nonatomic,retain) IBOutlet EGOImageView *coverImageView; 16 | @property (nonatomic,retain) IBOutlet EGOImageView *headerImageView; 17 | @property (nonatomic,retain) IBOutlet UILabel *nameLabel; 18 | @property (nonatomic,retain) IBOutlet UILabel *descriptionLabel; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/view/WeiboCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // WeiboCell.m 3 | // WaveTrans 4 | // 5 | // Created by hanchao on 13-11-26. 6 | // 7 | // 8 | 9 | #import "WeiboCell.h" 10 | 11 | #import "WaveTransMetadata.h" 12 | #import "EGOImageView.h" 13 | 14 | #import "VdiskJSON.h" 15 | 16 | @implementation WeiboCell 17 | 18 | - (id)initWithFrame:(CGRect)frame 19 | { 20 | self = [super initWithFrame:frame]; 21 | if (self) { 22 | // Initialization code 23 | } 24 | return self; 25 | } 26 | 27 | /* 28 | // Only override drawRect: if you perform custom drawing. 29 | // An empty implementation adversely affects performance during animation. 30 | - (void)drawRect:(CGRect)rect 31 | { 32 | // Drawing code 33 | } 34 | */ 35 | 36 | -(void)setMetadata:(WaveTransMetadata *)metadata 37 | { 38 | super.metadata = metadata; 39 | 40 | // CGFloat offsetX = 0; 41 | // UIColor *statusColor; 42 | // if (metadata.isReceived) { 43 | // offsetX = -4; 44 | // statusColor = RECEIVED_VIEW_COLOR;//[UIColor greenColor]; 45 | // }else{ 46 | // offsetX = 4; 47 | // statusColor = CREATED_VIEW_COLOR;//[UIColor blueColor]; 48 | // } 49 | // 50 | // UIView *statusView = [self.contentView viewWithTag:999]; 51 | // if (!statusView) { 52 | // statusView = [[[UIView alloc] init] autorelease]; 53 | // statusView.tag = 999; 54 | // [self.contentView addSubview:statusView]; 55 | // 56 | // CALayer *layer = [CALayer layer]; 57 | // layer.frame = CGRectMake(-offsetX/2, 0, ABS(offsetX), self.frame.size.height); 58 | // layer.shadowOffset = offsetX>0?CGSizeMake(-1, 0):CGSizeMake(1, 0); 59 | // layer.shadowColor = [[UIColor blackColor] CGColor]; 60 | // layer.shadowRadius = 4.0f; 61 | // layer.shadowOpacity = 0.80f; 62 | // layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; 63 | // 64 | // [statusView.layer addSublayer:layer]; 65 | // 66 | // } 67 | // statusView.frame = CGRectMake(offsetX>0?0:(self.bounds.size.width + offsetX), 0, ABS(offsetX), self.bounds.size.height); 68 | // statusView.backgroundColor = statusColor; 69 | 70 | // self.coverImageView.frame = CGRectMake(offsetX, 0, self.bounds.size.width, self.bounds.size.height); 71 | 72 | NSDictionary *jsonDict = [metadata.content JSONValue]; 73 | self.nameLabel.text = [jsonDict objectForKey:@"name"]; 74 | self.descriptionLabel.text = [jsonDict objectForKey:@"description"]; 75 | 76 | self.headerImageView.imageURL = [NSURL URLWithString:[jsonDict objectForKey:@"avatar_large"]]; 77 | self.coverImageView.imageURL = [NSURL URLWithString:[jsonDict objectForKey:@"cover_image"]]; 78 | } 79 | 80 | -(void)dealloc 81 | { 82 | self.headerImageView = nil; 83 | self.nameLabel = nil; 84 | self.descriptionLabel = nil; 85 | self.coverImageView = nil; 86 | 87 | [super dealloc]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Images/37x-Checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/37x-Checkmark.png -------------------------------------------------------------------------------- /Images/37x-Checkmark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/37x-Checkmark@2x.png -------------------------------------------------------------------------------- /Images/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/Default-568h@2x.png -------------------------------------------------------------------------------- /Images/SinaWeibo.bundle/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/SinaWeibo.bundle/images/close.png -------------------------------------------------------------------------------- /Images/SinaWeibo.bundle/images/close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/SinaWeibo.bundle/images/close@2x.png -------------------------------------------------------------------------------- /Images/UITabBarContactsTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/UITabBarContactsTemplate.png -------------------------------------------------------------------------------- /Images/UITabBarContactsTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/UITabBarContactsTemplate@2x.png -------------------------------------------------------------------------------- /Images/X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/X.png -------------------------------------------------------------------------------- /Images/X@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/X@2x.png -------------------------------------------------------------------------------- /Images/arrow_left@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/arrow_left@2x.png -------------------------------------------------------------------------------- /Images/arrow_right@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/arrow_right@2x.png -------------------------------------------------------------------------------- /Images/audio_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/audio_bg.png -------------------------------------------------------------------------------- /Images/binary_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/binary_bg.png -------------------------------------------------------------------------------- /Images/error.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/error.wav -------------------------------------------------------------------------------- /Images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/icon.png -------------------------------------------------------------------------------- /Images/photo_cell_alpha_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/photo_cell_alpha_cover.png -------------------------------------------------------------------------------- /Images/play_beep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_beep.png -------------------------------------------------------------------------------- /Images/play_beep@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_beep@2x.png -------------------------------------------------------------------------------- /Images/play_beep_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_beep_disable.png -------------------------------------------------------------------------------- /Images/play_beep_disable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_beep_disable@2x.png -------------------------------------------------------------------------------- /Images/play_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_btn.png -------------------------------------------------------------------------------- /Images/play_btn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/play_btn@2x.png -------------------------------------------------------------------------------- /Images/quotes_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/quotes_l.png -------------------------------------------------------------------------------- /Images/quotes_l@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/quotes_l@2x.png -------------------------------------------------------------------------------- /Images/quotes_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/quotes_r.png -------------------------------------------------------------------------------- /Images/quotes_r@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/quotes_r@2x.png -------------------------------------------------------------------------------- /Images/sent_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/sent_btn.png -------------------------------------------------------------------------------- /Images/sent_btn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/sent_btn@2x.png -------------------------------------------------------------------------------- /Images/setting_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/setting_btn.png -------------------------------------------------------------------------------- /Images/setting_btn@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/setting_btn@2x.png -------------------------------------------------------------------------------- /Images/success_1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/success_1.wav -------------------------------------------------------------------------------- /Images/tableview_sep_line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/tableview_sep_line.png -------------------------------------------------------------------------------- /Images/tableview_sep_line@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/tableview_sep_line@2x.png -------------------------------------------------------------------------------- /Images/text_bg@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/text_bg@2x.png -------------------------------------------------------------------------------- /Images/top_gb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/top_gb.png -------------------------------------------------------------------------------- /Images/top_gb@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/Images/top_gb@2x.png -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | zh_CN 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.sina.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UIStatusBarHidden 26 | 27 | UISupportedInterfaceOrientations 28 | 29 | UIInterfaceOrientationPortrait 30 | 31 | CFBundleURLTypes 32 | 33 | 34 | CFBundleURLSchemes 35 | 36 | sinaweibosso.1396484607 37 | sinavdisksso.1396484607 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WaveTrans 2 | 3 | [![paypaldonate](https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VW7YCWNMQ7ZXY) 4 | 5 | ![](http://image.sinastorage.com/donate.png) 6 | 7 | =========================================================================== 8 | Let's teach the machines to sing 9 | 10 | Try 声波传输! --- 用声音传输数据 11 | 12 | 采用仿生学技术,利用声音实现文件的快速传输。采用跨平台的技术,实现手机与PC之间,或者手机之间的图片、文字、链接的传输, 以及设备间配对等。一键操作,2秒钟搞定。 13 | 14 | 同时社交功能实现了微博互粉、近距离广播、电子名片交换等功能, 将来可以实现开放协议的便捷电子支付功能。 15 | 16 | =========================================================================== 17 | 18 | 声波传输如何工作? 19 | 20 | 声波传输技术由两部分组成:音频协议与网络协议。音频协议将待传数据编码为一系列选定频率的音调;网络协议则将数据以键值形式存入服务器,其中键为与数据唯一对应的10个字符。 21 | 22 | 音频协议 23 | 24 | 音频协议的原理很简单,易于实现。建立一个含有32个字符([0-9,a-v])的表,并将每个字符映射到频率表。频率表是根据乐理,通过伴音的计算生成。 25 | 26 | 0 = 1760hz 27 | 28 | 1 = 1864hz 29 | 30 | ...... 31 | 32 | v = 10.5khz 33 | 34 | 一个完整的声波包包含20个音(即20个字符),每87.2毫秒发一个音 。前两位为信息头,采用“hj”,用以通知接收端开始接收。中间10位为有效的信息位,是有效的传输信息,即Key值经过映射后的频率信息。最后8位为RS(Reed-Solomon)校验位,通过RS校验算法,对中间10位进行计算,生成8位的校验信息 35 | 36 | [头][有效数据][校验位] 37 | 38 | 校验主要用来处理由于噪声干扰造成的信息接收错误。通过RS校验,可以纠正25%的错误信息。 39 | 40 | 41 | 发送端(编码器) 42 | 43 | 发送端设备只需能够发送1.7khz到10.5khz的正弦声波即可。为了将发送出的声波变得更好听,可以对声音进行一些美化处理,比如在我们的例子中,采用了椭圆形窗对声波进行了音量上的优化。 44 | 45 | 46 | 接收端(解码器) 47 | 48 | 接收端需要记录声音,并将其进行解码以及容错处理。其对算法的要求相对较高,降噪及容错处理对能否得到正确的解码信息是至关重要的。所以接收端需要一定的数字运算能力,对设备的硬件配置有一定的要求。对于算法的细节,我们会逐步的公开并开源。 49 | 50 | 51 | 网络协议 52 | 53 | 音频协议的最大局限性,在于其较低的传输效率。 54 | 55 | 为了解决大量数据的传输问题,我们提供RESTful Api,这样发送设备可以将照片上传到云端,并获取云端返回的Key,将Key通过声波发送出去。接收端通过收到的Key从云端获取数据。 56 | 57 | http://rest.sinaapp.com/?a=api 58 | 59 | =========================================================================== 60 | PACKAGING LIST: 61 | 62 | EAGLView.h 63 | EAGLView.m 64 | 65 | This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. 66 | 67 | aurio_helper.cpp 68 | aurio_helper.h 69 | 70 | Helper functions for manipulating the remote i/o audio unit, responsible for setting up the remote i/o. 71 | 72 | AppDelegate.h 73 | AppDelegate.mm 74 | 75 | 76 | The application delegate for the aurioTouch2 app, responsible for handling touch events and drawing. 77 | 78 | FFTBufferManager.cpp 79 | FFTBufferManager.h 80 | 81 | This class manages buffering and computation for FFT analysis on input audio data. The methods provided are used to grab the audio, buffer it, and perform the FFT when sufficient data is available. 82 | 83 | CAMath.h 84 | 85 | CAMath is a helper class for various math functions. 86 | 87 | CADebugMacros.h 88 | CADebugMacros.cpp 89 | 90 | A helper class for printing debug messages. 91 | 92 | CAXException.h 93 | CAXException.cpp 94 | 95 | A helper class for exception handling. 96 | 97 | CAStreamBasicDescription.cpp 98 | CAStreamBasicDescription.h 99 | 100 | A helper class for AudioStreamBasicDescription handling and manipulation. 101 | 102 | 103 | -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "size" : "57x57", 20 | "idiom" : "iphone", 21 | "filename" : "icon57.png", 22 | "scale" : "1x" 23 | }, 24 | { 25 | "size" : "57x57", 26 | "idiom" : "iphone", 27 | "filename" : "icon114.png", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "size" : "60x60", 32 | "idiom" : "iphone", 33 | "filename" : "icon120.png", 34 | "scale" : "2x" 35 | } 36 | ], 37 | "info" : { 38 | "version" : 1, 39 | "author" : "xcode" 40 | } 41 | } -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/AppIcon.appiconset/icon114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/AppIcon.appiconset/icon114.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/AppIcon.appiconset/icon120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/AppIcon.appiconset/icon120.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/AppIcon.appiconset/icon57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/AppIcon.appiconset/icon57.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "filename" : "launchImage@2x.png", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "extent" : "full-screen", 13 | "idiom" : "iphone", 14 | "subtype" : "retina4", 15 | "filename" : "launchImage-568h@2x.png", 16 | "minimum-system-version" : "7.0", 17 | "orientation" : "portrait", 18 | "scale" : "2x" 19 | }, 20 | { 21 | "orientation" : "portrait", 22 | "idiom" : "iphone", 23 | "extent" : "full-screen", 24 | "filename" : "launchImage.png", 25 | "scale" : "1x" 26 | }, 27 | { 28 | "orientation" : "portrait", 29 | "idiom" : "iphone", 30 | "extent" : "full-screen", 31 | "filename" : "launchImage@2x-1.png", 32 | "scale" : "2x" 33 | }, 34 | { 35 | "orientation" : "portrait", 36 | "idiom" : "iphone", 37 | "extent" : "full-screen", 38 | "filename" : "launchImage-568h@2x-1.png", 39 | "subtype" : "retina4", 40 | "scale" : "2x" 41 | } 42 | ], 43 | "info" : { 44 | "version" : 1, 45 | "author" : "xcode" 46 | } 47 | } -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage-568h@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage-568h@2x-1.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage-568h@2x.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage@2x-1.png -------------------------------------------------------------------------------- /WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/WaveTrans/Images.xcassets/LaunchImage.launchimage/launchImage@2x.png -------------------------------------------------------------------------------- /WaveTrans_Prefix.pch: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: aurioTouch2_Prefix.pch 4 | Abstract: Prefix file 5 | Version: 1.0 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2011 Apple Inc. All Rights Reserved. 46 | 47 | 48 | */ 49 | 50 | 51 | #ifdef __OBJC__ 52 | 53 | #import 54 | #import 55 | #import "VdiskUtil.h" 56 | #import "VdiskSDK.h" 57 | #import "VdiskError__.h" 58 | 59 | #define kWeiboAppKey @"1396484607" 60 | #define kWeiboAppSecret @"d391e9c2aadd796a6a42e65802dd1278" 61 | #define kWeiboAppRedirectURI @"http://2.vauth.appsina.com/callback.php" 62 | 63 | #define kVdiskAppKey @"4131924685" 64 | #define kVdiskAppSecret @"270fbfca4cb7032bbeb400f860aa26ce" 65 | #define kVdiskAppRedirectURI @"https://vauth.appsina.com/callback.php" 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /freq_util/bb_header.h: -------------------------------------------------------------------------------- 1 | // 2 | // bb_header.h 3 | // BBSDK 4 | // 5 | // Created by Littlebox on 13-5-15. 6 | // Copyright (c) 2013年 Littlebox. All rights reserved. 7 | // 8 | 9 | #ifndef BBSDK_bb_header_h 10 | #define BBSDK_bb_header_h 11 | 12 | #include "bb_freq_util.h" 13 | #include "rscode.h" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /html/css/main.css: -------------------------------------------------------------------------------- 1 | body { margin: 0px; padding: 0px; background:#FFF; font-family:"Lucida Grande",Arial,Helvetica,Verdana,sans-serif; overflow:hidden; 2 | /*-webkit-touch-callout: none;*/ -webkit-text-size-adjust: none; -webkit-tap-highlight-color: rgba(0,0,0,0.1); /*-webkit-user-select: none;*/} 3 | body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,select,textarea,p,blockquote,th,td { 4 | margin: 0; 5 | padding: 0; 6 | } 7 | input, select { vertical-align: baseline; } 8 | textarea { font-family: "Lucida Grande", Arial, Helvetica, Verdana, sans-serif; } 9 | input[type=text],input[type=password],textarea { background: #fff; color: #000; font-size: 12px; } 10 | label { cursor:pointer; } 11 | table { border-collapse: collapse; border-spacing: 0; font-size: 100%;} 12 | fieldset,img { border: 0; } 13 | address,caption,cite,code,dfn,em,th,var { font-style: normal; font-weight: normal; } 14 | strong { font-weight: bold; font-style: normal; } 15 | em { font-weight: normal; font-style: italic; } 16 | ul { list-style: none; } 17 | .clear { clear:both; line-height:0; font-size:0; } 18 | .clearit:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; } 19 | .clearit { zoom:1; } 20 | .rr { float:right;} 21 | .ll { float:left; margin:0 10px 0 0; } 22 | span.plus_wrapper { /*display:block;*/ position:relative; padding:0 5px; } 23 | span.ico_plus { display:block;width:27px;height:27px; position:absolute; bottom:-7px; right:-5px; } 24 | span.ico_plus_black { display:block;width:22px;height:22px; position:absolute; bottom:-7px; right:-5px; } 25 | 26 | small.grey { font-size:12px; color:#CCC; } 27 | 28 | img { max-width:300px; /*border:1px solid #777; -webkit-box-shadow: 2px 2px 2px #AAA;*/ } 29 | 30 | img.noBorder { max-width:300px; border:none; -webkit-box-shadow: none; } 31 | 32 | a:link, a:active, a:visited { text-decoration: none; color: #21759B; } 33 | a:hover { text-decoration: none; color: #02A3FB; } 34 | 35 | 36 | .box_shadow5 { 37 | 38 | -webkit-box-shadow: 0px 0px 5px #000; /* Saf3-4, iOS 4.0.2 - 4.2, Android 2.3+ */ 39 | -moz-box-shadow: 0px 0px 5px #000; /* FF3.5 - 3.6 */ 40 | box-shadow: 0px 0px 5px #000; /* Opera 10.5, IE9, FF4+, Chrome 6+, iOS 5 */ 41 | } 42 | 43 | .box_shadow10 { 44 | 45 | -webkit-box-shadow: 0px 0px 10px #000; /* Saf3-4, iOS 4.0.2 - 4.2, Android 2.3+ */ 46 | -moz-box-shadow: 0px 0px 10px #000; /* FF3.5 - 3.6 */ 47 | box-shadow: 0px 0px 10px #000; /* Opera 10.5, IE9, FF4+, Chrome 6+, iOS 5 */ 48 | } 49 | 50 | .box_shadow15 { 51 | 52 | -webkit-box-shadow: 0px 0px 15px #000; /* Saf3-4, iOS 4.0.2 - 4.2, Android 2.3+ */ 53 | -moz-box-shadow: 0px 0px 15px #000; /* FF3.5 - 3.6 */ 54 | box-shadow: 0px 0px 15px #000; /* Opera 10.5, IE9, FF4+, Chrome 6+, iOS 5 */ 55 | } 56 | 57 | .box_shadow_light { 58 | 59 | -webkit-box-shadow: 0px 0px 15px #fff; /* Saf3-4, iOS 4.0.2 - 4.2, Android 2.3+ */ 60 | -moz-box-shadow: 0px 0px 15px #fff; /* FF3.5 - 3.6 */ 61 | box-shadow: 0px 0px 15px #fff; /* Opera 10.5, IE9, FF4+, Chrome 6+, iOS 5 */ 62 | } -------------------------------------------------------------------------------- /html/images/bg-v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/bg-v3.png -------------------------------------------------------------------------------- /html/images/cate_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_1.png -------------------------------------------------------------------------------- /html/images/cate_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_13.png -------------------------------------------------------------------------------- /html/images/cate_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_2.png -------------------------------------------------------------------------------- /html/images/cate_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_20.png -------------------------------------------------------------------------------- /html/images/cate_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_21.png -------------------------------------------------------------------------------- /html/images/cate_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_23.png -------------------------------------------------------------------------------- /html/images/cate_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_3.png -------------------------------------------------------------------------------- /html/images/cate_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_4.png -------------------------------------------------------------------------------- /html/images/cate_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_5.png -------------------------------------------------------------------------------- /html/images/cate_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_6.png -------------------------------------------------------------------------------- /html/images/cate_75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_75.png -------------------------------------------------------------------------------- /html/images/cate_guess_you_like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_guess_you_like.png -------------------------------------------------------------------------------- /html/images/cate_other.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/cate_other.png -------------------------------------------------------------------------------- /html/images/ipad_doc_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_doc_icon.png -------------------------------------------------------------------------------- /html/images/ipad_doc_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_doc_icon@2x.png -------------------------------------------------------------------------------- /html/images/ipad_edu_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_edu_icon.png -------------------------------------------------------------------------------- /html/images/ipad_edu_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_edu_icon@2x.png -------------------------------------------------------------------------------- /html/images/ipad_it_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_it_icon.png -------------------------------------------------------------------------------- /html/images/ipad_it_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_it_icon@2x.png -------------------------------------------------------------------------------- /html/images/ipad_life_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_life_icon.png -------------------------------------------------------------------------------- /html/images/ipad_life_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_life_icon@2x.png -------------------------------------------------------------------------------- /html/images/ipad_random_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_random_icon.png -------------------------------------------------------------------------------- /html/images/ipad_random_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_random_icon@2x.png -------------------------------------------------------------------------------- /html/images/ipad_special.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_special.png -------------------------------------------------------------------------------- /html/images/ipad_special@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/html/images/ipad_special@2x.png -------------------------------------------------------------------------------- /html/js/common.js: -------------------------------------------------------------------------------- 1 | var domain = "api.weipan.cn"; 2 | var scheme = "native"; 3 | var callback_id = 0; 4 | 5 | function run_command(path, parms) { 6 | 7 | if (!this.nativeBridge) { 8 | 9 | this.nativeBridge = document.createElement("iframe"); 10 | this.nativeBridge.setAttribute("style", "display:none;"); 11 | this.nativeBridge.setAttribute("height", "0px"); 12 | this.nativeBridge.setAttribute("width", "0px"); 13 | this.nativeBridge.setAttribute("frameborder", "0"); 14 | document.documentElement.appendChild(this.nativeBridge); 15 | } 16 | 17 | callback_id ++; 18 | 19 | var url = scheme + "://" + domain + "/" + path + "?callback_id=" + callback_id + "&" + parms; 20 | 21 | this.nativeBridge.src = url; 22 | } 23 | 24 | function JSLog(msg) { 25 | 26 | run_command('JSLog', 'msg=' + encodeURIComponent(msg)); 27 | } 28 | 29 | 30 | /** 31 | * 回到页面顶部 32 | * @param acceleration 加速度 33 | * @param time 时间间隔 (毫秒) 34 | **/ 35 | 36 | function goTop(acceleration, time) { 37 | 38 | acceleration = acceleration || 0.1; 39 | time = time || 16; 40 | 41 | var x1 = 0; 42 | var y1 = 0; 43 | var x2 = 0; 44 | var y2 = 0; 45 | var x3 = 0; 46 | var y3 = 0; 47 | 48 | if (document.documentElement) { 49 | x1 = document.documentElement.scrollLeft || 0; 50 | y1 = document.documentElement.scrollTop || 0; 51 | } 52 | if (document.body) { 53 | x2 = document.body.scrollLeft || 0; 54 | y2 = document.body.scrollTop || 0; 55 | } 56 | var x3 = window.scrollX || 0; 57 | var y3 = window.scrollY || 0; 58 | 59 | // 滚动条到页面顶部的水平距离 60 | var x = Math.max(x1, Math.max(x2, x3)); 61 | // 滚动条到页面顶部的垂直距离 62 | var y = Math.max(y1, Math.max(y2, y3)); 63 | 64 | // 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小 65 | var speed = 1 + acceleration; 66 | window.scrollTo(Math.floor(x / speed), Math.floor(y / speed)); 67 | 68 | // 如果距离不为零, 继续调用迭代本函数 69 | if(x > 0 || y > 0) { 70 | var invokeFunction = "goTop(" + acceleration + ", " + time + ")"; 71 | window.setTimeout(invokeFunction, time); 72 | } 73 | } -------------------------------------------------------------------------------- /html/js/jquery.lazyload.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Lazy Load - jQuery plugin for lazy loading images 3 | * 4 | * Copyright (c) 2007-2011 Mika Tuupola 5 | * 6 | * Licensed under the MIT license: 7 | * http://www.opensource.org/licenses/mit-license.php 8 | * 9 | * Project home: 10 | * http://www.appelsiini.net/projects/lazyload 11 | * 12 | * Version: 1.6.0 13 | * 14 | */ 15 | (function(a){a.fn.lazyload=function(b){var c={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:window,skip_invisible:!0};b&&(null!==b.failurelimit&&(b.failure_limit=b.failurelimit,delete b.failurelimit),a.extend(c,b));var d=this;return 0==c.event.indexOf("scroll")&&a(c.container).bind(c.event,function(b){var e=0;d.each(function(){if(c.skip_invisible&&!a(this).is(":visible"))return;if(!a.abovethetop(this,c)&&!a.leftofbegin(this,c))if(!a.belowthefold(this,c)&&!a.rightoffold(this,c))a(this).trigger("appear");else if(++e>c.failure_limit)return!1});var f=a.grep(d,function(a){return!a.loaded});d=a(f)}),this.each(function(){var b=this;b.loaded=!1,a(b).one("appear",function(){this.loaded||a("").bind("load",function(){a(b).hide().attr("src",a(b).data("original"))[c.effect](c.effectspeed),b.loaded=!0}).attr("src",a(b).data("original"))}),0!=c.event.indexOf("scroll")&&a(b).bind(c.event,function(c){b.loaded||a(b).trigger("appear")})}),a(c.container).trigger(c.event),this},a.belowthefold=function(b,c){if(c.container===undefined||c.container===window)var d=a(window).height()+a(window).scrollTop();else var d=a(c.container).offset().top+a(c.container).height();return d<=a(b).offset().top-c.threshold},a.rightoffold=function(b,c){if(c.container===undefined||c.container===window)var d=a(window).width()+a(window).scrollLeft();else var d=a(c.container).offset().left+a(c.container).width();return d<=a(b).offset().left-c.threshold},a.abovethetop=function(b,c){if(c.container===undefined||c.container===window)var d=a(window).scrollTop();else var d=a(c.container).offset().top;return d>=a(b).offset().top+c.threshold+a(b).height()},a.leftofbegin=function(b,c){if(c.container===undefined||c.container===window)var d=a(window).scrollLeft();else var d=a(c.container).offset().left;return d>=a(b).offset().left+c.threshold+a(b).width()},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0,container:window})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0,container:window})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0,container:window})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0,container:window})}})})(jQuery) 16 | -------------------------------------------------------------------------------- /html/js/jquery.scrollstop.js: -------------------------------------------------------------------------------- 1 | /* http://james.padolsey.com/javascript/special-scroll-events-for-jquery/ */ 2 | 3 | (function(){ 4 | 5 | var special = jQuery.event.special, 6 | uid1 = 'D' + (+new Date()), 7 | uid2 = 'D' + (+new Date() + 1); 8 | 9 | special.scrollstart = { 10 | setup: function() { 11 | 12 | var timer, 13 | handler = function(evt) { 14 | 15 | var _self = this, 16 | _args = arguments; 17 | 18 | if (timer) { 19 | clearTimeout(timer); 20 | } else { 21 | evt.type = 'scrollstart'; 22 | jQuery.event.handle.apply(_self, _args); 23 | } 24 | 25 | timer = setTimeout( function(){ 26 | timer = null; 27 | }, special.scrollstop.latency); 28 | 29 | }; 30 | 31 | jQuery(this).bind('scroll', handler).data(uid1, handler); 32 | 33 | }, 34 | teardown: function(){ 35 | jQuery(this).unbind( 'scroll', jQuery(this).data(uid1) ); 36 | } 37 | }; 38 | 39 | special.scrollstop = { 40 | latency: 300, 41 | setup: function() { 42 | 43 | var timer, 44 | handler = function(evt) { 45 | 46 | var _self = this, 47 | _args = arguments; 48 | 49 | if (timer) { 50 | clearTimeout(timer); 51 | } 52 | 53 | timer = setTimeout( function(){ 54 | 55 | timer = null; 56 | evt.type = 'scrollstop'; 57 | jQuery.event.handle.apply(_self, _args); 58 | 59 | }, special.scrollstop.latency); 60 | 61 | }; 62 | 63 | jQuery(this).bind('scroll', handler).data(uid2, handler); 64 | 65 | }, 66 | teardown: function() { 67 | jQuery(this).unbind( 'scroll', jQuery(this).data(uid2) ); 68 | } 69 | }; 70 | 71 | })(); -------------------------------------------------------------------------------- /iPublicUtility/CABitOperations.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudSide/WaveTrans/e17e5bbaad8edea9493b65150f4b4bd6a7eb691e/iPublicUtility/CABitOperations.h -------------------------------------------------------------------------------- /iPublicUtility/CADebugMacros.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: CADebugMacros.cpp 4 | Abstract: Helper class for printing debug messages 5 | Version: 1.21 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2010 Apple Inc. All Rights Reserved. 46 | 47 | 48 | */ 49 | 50 | #include "CADebugMacros.h" 51 | #include 52 | #include 53 | #if TARGET_API_MAC_OSX 54 | #include 55 | #endif 56 | 57 | #if DEBUG 58 | #include 59 | 60 | void DebugPrint(const char *fmt, ...) 61 | { 62 | va_list args; 63 | va_start(args, fmt); 64 | vprintf(fmt, args); 65 | va_end(args); 66 | } 67 | #endif // DEBUG 68 | 69 | #if TARGET_API_MAC_OSX 70 | void LogError(const char *fmt, ...) 71 | { 72 | va_list args; 73 | va_start(args, fmt); 74 | #if DEBUG 75 | vprintf(fmt, args); 76 | #endif 77 | vsyslog(LOG_ERR, fmt, args); 78 | va_end(args); 79 | } 80 | 81 | void LogWarning(const char *fmt, ...) 82 | { 83 | va_list args; 84 | va_start(args, fmt); 85 | #if DEBUG 86 | vprintf(fmt, args); 87 | #endif 88 | vsyslog(LOG_WARNING, fmt, args); 89 | va_end(args); 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /iPublicUtility/CAMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: CAMath.h 4 | Abstract: Helper class for various math functions 5 | Version: 1.21 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2010 Apple Inc. All Rights Reserved. 46 | 47 | 48 | */ 49 | 50 | #ifndef __CAMath_h__ 51 | #define __CAMath_h__ 52 | 53 | #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 54 | #include 55 | #else 56 | #include 57 | #endif 58 | 59 | inline bool fiszero(Float64 f) { return (f == 0.); } 60 | inline bool fiszero(Float32 f) { return (f == 0.f); } 61 | 62 | inline bool fnonzero(Float64 f) { return !fiszero(f); } 63 | inline bool fnonzero(Float32 f) { return !fiszero(f); } 64 | 65 | inline bool fequal(const Float64 &a, const Float64 &b) { return a == b; } 66 | inline bool fequal(const Float32 &a, const Float32 &b) { return a == b; } 67 | 68 | inline bool fnotequal(const Float64 &a, const Float64 &b) { return !fequal(a, b); } 69 | inline bool fnotequal(const Float32 &a, const Float32 &b) { return !fequal(a, b); } 70 | 71 | #endif // __CAMath_h__ 72 | -------------------------------------------------------------------------------- /iPublicUtility/CAXException.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: CAXException.cpp 4 | Abstract: Helper class for excpetion handling 5 | Version: 1.21 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2010 Apple Inc. All Rights Reserved. 46 | 47 | 48 | */ 49 | 50 | 51 | #include "CAXException.h" 52 | 53 | CAXException::WarningHandler CAXException::sWarningHandler = NULL; 54 | -------------------------------------------------------------------------------- /kiss_fft/kiss_fastfir.h: -------------------------------------------------------------------------------- 1 | // 2 | // kiss_fastfir.h 3 | // BBSDK 4 | // 5 | // Created by Bruce on 13-5-22. 6 | // Copyright (c) 2013年 Littlebox. All rights reserved. 7 | // 8 | 9 | #ifndef BBSDK_kiss_fastfir_h 10 | #define BBSDK_kiss_fastfir_h 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | /* 25 | Some definitions that allow real or complex filtering 26 | */ 27 | #ifdef REAL_FASTFIR 28 | #define MIN_FFT_LEN 2048 29 | #include "kiss_fftr.h" 30 | 31 | typedef kiss_fft_scalar kffsamp_t; 32 | typedef kiss_fftr_cfg kfcfg_t; 33 | #define FFT_ALLOC kiss_fftr_alloc 34 | #define FFTFWD kiss_fftr 35 | #define FFTINV kiss_fftri 36 | #else 37 | #define MIN_FFT_LEN 1024 38 | typedef kiss_fft_cpx kffsamp_t; 39 | typedef kiss_fft_cfg kfcfg_t; 40 | #define FFT_ALLOC kiss_fft_alloc 41 | #define FFTFWD kiss_fft 42 | #define FFTINV kiss_fft 43 | #endif 44 | 45 | typedef struct kiss_fastfir_state *kiss_fastfir_cfg; 46 | 47 | 48 | 49 | kiss_fastfir_cfg kiss_fastfir_alloc(const kffsamp_t * imp_resp,size_t n_imp_resp, 50 | size_t * nfft,void * mem,size_t*lenmem); 51 | 52 | /* see do_file_filter for usage */ 53 | size_t kiss_fastfir( kiss_fastfir_cfg cfg, kffsamp_t * inbuf, kffsamp_t * outbuf, size_t n, size_t *offset); 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /kiss_fft/kiss_fftr.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FTR_H 2 | #define KISS_FTR_H 3 | 4 | #include "kiss_fft.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | /* 11 | 12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 13 | 14 | 15 | 16 | */ 17 | 18 | typedef struct kiss_fftr_state *kiss_fftr_cfg; 19 | 20 | 21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); 22 | /* 23 | nfft must be even 24 | 25 | If you don't care to allocate space, use mem = lenmem = NULL 26 | */ 27 | 28 | 29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); 30 | /* 31 | input timedata has nfft scalar points 32 | output freqdata has nfft/2+1 complex points 33 | */ 34 | 35 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); 36 | /* 37 | input freqdata has nfft/2+1 complex points 38 | output timedata has nfft scalar points 39 | */ 40 | 41 | #define kiss_fftr_free free 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /main.mm: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: main.m 4 | Abstract: main file 5 | Version: 1.0 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2011 Apple Inc. All Rights Reserved. 46 | 47 | 48 | */ 49 | 50 | #import 51 | #import "AppDelegate.h" 52 | 53 | int main(int argc, char *argv[]) { 54 | 55 | /* 56 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 57 | int retVal = UIApplicationMain(argc, argv, nil, nil); 58 | [pool release]; 59 | return retVal; 60 | */ 61 | 62 | @autoreleasepool { 63 | 64 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /queue/queue.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // queue.cpp 3 | // aurioTouch2 4 | // 5 | // Created by Bruce on 13-11-6. 6 | // 7 | // 8 | 9 | #include "queue.h" 10 | #include 11 | #include 12 | 13 | void init_queue(queue *q, int length) 14 | { 15 | if (length >= QUEUESIZE) 16 | printf("Warning: queue overflow enqueue x=%d\n", length); 17 | 18 | q->first = 0; 19 | q->last = length-1; 20 | q->count = 0; 21 | q->length = length; 22 | } 23 | 24 | void enqueue_adv(queue *q, queue_item x) 25 | { 26 | queue_item xx = x; 27 | 28 | if (!queue_is_empty(q)) { 29 | 30 | xx = x * 0.5 + q->q[q->last] * 0.5; 31 | 32 | if (xx <= x) { 33 | 34 | xx = x; 35 | } 36 | 37 | if (xx < 0.05) { 38 | 39 | xx = (queue_item)0.0; 40 | } 41 | 42 | /* 43 | 44 | if (q->q[q->last] >= xx) { 45 | 46 | xx = (queue_item)0.0; 47 | 48 | } else { 49 | 50 | q->q[q->last] = (queue_item)0.0; 51 | } 52 | 53 | if (xx < 0.05) { 54 | 55 | xx = (queue_item)0.0; 56 | } 57 | */ 58 | } 59 | 60 | enqueue(q, xx); 61 | } 62 | 63 | void enqueue(queue *q, queue_item x) 64 | { 65 | if (q->count >= q->length) 66 | dequeue(q); 67 | //else 68 | { 69 | q->last = (q->last+1) % q->length; 70 | q->q[ q->last ] = x; 71 | q->count = q->count + 1; 72 | } 73 | } 74 | 75 | queue_item dequeue(queue *q) 76 | { 77 | queue_item x; 78 | 79 | if (q->count <= 0) printf("Warning: empty queue dequeue.\n"); 80 | else { 81 | x = q->q[ q->first ]; 82 | q->first = (q->first+1) % q->length; 83 | q->count = q->count - 1; 84 | } 85 | 86 | return(x); 87 | } 88 | 89 | int queue_is_empty(queue *q) 90 | { 91 | if (q->count <= 0) return (true); 92 | else return (false); 93 | } 94 | 95 | queue_item queue_item_at_index(queue *q, int index) 96 | { 97 | int i = q->first; 98 | 99 | if (index > 0) { 100 | 101 | i = (i + index) % q->length; 102 | } 103 | 104 | return q->q[i]; 105 | } 106 | 107 | void print_queue(queue *q) 108 | { 109 | int i; 110 | 111 | i = q->first; 112 | 113 | while (i != q->last) { 114 | 115 | printf("%f ",q->q[i]); 116 | i = (i+1) % q->length; 117 | } 118 | 119 | printf("%f ",q->q[i]); 120 | printf("\n"); 121 | } -------------------------------------------------------------------------------- /queue/queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // queue.h 3 | // aurioTouch2 4 | // 5 | // Created by Bruce on 13-11-6. 6 | // 7 | // 8 | 9 | #ifndef aurioTouch2_queue_h 10 | #define aurioTouch2_queue_h 11 | 12 | 13 | #define QUEUESIZE 128 14 | 15 | typedef float queue_item; 16 | 17 | typedef struct { 18 | 19 | queue_item q[QUEUESIZE+1] = {0}; /* body of queue */ 20 | int first; /* position of first element */ 21 | int last; /* position of last element */ 22 | int count; /* number of queue elements */ 23 | int length; 24 | 25 | } queue; 26 | 27 | void init_queue(queue *q, int length); 28 | void enqueue(queue *q, queue_item x); 29 | void enqueue_adv(queue *q, queue_item x); 30 | queue_item dequeue(queue *q); 31 | int queue_is_empty(queue *q); 32 | void print_queue(queue *q); 33 | queue_item queue_item_at_index(queue *q, int index); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /rscode/rscode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon encoder. This code is taken from Phil Karn's libfec then 5 | * editted and packed into a pair of .c and .h files. 6 | * 7 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 8 | * (libfec is released under the GNU Lesser General Public License.) 9 | * 10 | * Copyright (C) 2006-2011 Kentaro Fukuchi 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #ifndef __RSCODE_H__ 28 | #define __RSCODE_H__ 29 | 30 | #define RS_SYMSIZE 5 31 | #define RS_GFPOLY 0x25 32 | #define RS_FCR 1 33 | #define RS_PRIM 1 34 | #define RS_NROOTS 8 35 | #define RS_DATA_LEN 10 36 | #define RS_TOTAL_LEN (RS_DATA_LEN + RS_NROOTS) 37 | #define RS_PAD ((1<