-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGDLib.cpp
More file actions
159 lines (130 loc) · 5.07 KB
/
GDLib.cpp
File metadata and controls
159 lines (130 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "GDLib.h"
#include <sstream>
#include "BaseXX.h"
#include "KSDes.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "jni.h"
#if COCOS2D_VERSION<0x00020000
#include "android/jni/JniHelper.h"
#include "android/jni/SystemInfoJni.h"
#else
#include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include "platform/android/jni/JniHelper.h"
#endif
#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <UIKit/UIKit.h>
#import <StoreKit/SKStoreProductViewController.h>
#import "AppController.h"
@interface AppController(GraphDog) <SKStoreProductViewControllerDelegate>
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController;
@end
@implementation AppController(GraphDog)
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
[viewController dismissViewControllerAnimated:YES completion:nil];
}
@end
#endif
namespace GraphDogLib {
std::string GDCreateToken(string auID,string udid,string flag,string lang,string nick,string email,string platform,string cTime,string secretKey,string dInfo){
string msg = auID;
msg.append("||");
msg.append(udid);
msg.append("||");
msg.append(flag);
msg.append("||");
msg.append(lang);
msg.append("||");
msg.append(nick);
msg.append("||");
msg.append(email);
msg.append("||");
msg.append(platform);
msg.append("||");
msg.append(cTime);
msg.append("||");
msg.append(dInfo);
msg.append("||");
return toBase64(desEncryption(secretKey, msg));
}
void replaceString( std::string & strCallId, const char * pszBefore, const char * pszAfter )
{
size_t iPos = strCallId.find( pszBefore );
size_t iBeforeLen = strlen( pszBefore );
while( iPos < std::string::npos )
{
strCallId.replace( iPos, iBeforeLen, pszAfter );
iPos = strCallId.find( pszBefore, iPos );
}
}
string JsonObjectToString(JsonBox::Object _obj){
ostringstream oss;
oss << _obj;
return oss.str();
}
JsonBox::Object StringToJsonObject(string _str){
//명령문자열 json::value 로 변환
JsonBox::Value result;
result.loadFromString(_str.c_str());
//명령문자열 json::object 로 변환
JsonBox::Object resultobj = result.getObject();
return resultobj;
}
string getLocalCode()
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
{
const char* tempCode;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
// get the current language code.(such as English is "en", Chinese is "zh" and so on)
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
tempCode = [languageCode cStringUsingEncoding:NSASCIIStringEncoding];
return tempCode;
}
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
{
string tempCode = getCurrentLanguageJNI();
return tempCode;
}
#endif
}
void openReview(string appid)
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
NSString *urlstring = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%s&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software",appid.c_str()];
NSURL *url = [NSURL URLWithString:urlstring];
[[UIApplication sharedApplication] openURL:url];
#endif
}
void openUpdate(string appid)
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
NSString *urlstring = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%s",appid.c_str()];
NSURL *url = [NSURL URLWithString:urlstring];
[[UIApplication sharedApplication] openURL:url];
#endif
}
void openAppStore(string appid){
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
if(NSClassFromString(@"SKStoreProductViewController")) { // iOS6 이상인지 체크
AppController *appDelegate = (AppController *)[[UIApplication sharedApplication]delegate];
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
storeViewController.delegate = appDelegate;
NSDictionary *parameters = @{SKStoreProductParameterITunesItemIdentifier:[NSNumber numberWithInt:atoi(appid.c_str())]};
[storeViewController loadProductWithParameters:parameters completionBlock:^(BOOL result, NSError *error) {
if (result){
[appDelegate.viewController presentViewController:storeViewController animated:YES completion:nil];
}
}];
}else{
NSString *urlstring = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%s",appid.c_str()];
NSURL *url = [NSURL URLWithString:urlstring];
[[UIApplication sharedApplication] openURL:url];
}
#endif
}
}