Remove the code of plugin.

This commit is contained in:
zhangbin 2013-09-05 14:08:07 +08:00
parent 850efa5eac
commit b550d6c429
694 changed files with 0 additions and 61465 deletions

98
plugin/.gitignore vendored
View File

@ -1,98 +0,0 @@
# Ignore thumbnails created by windows
Thumbs.db
# Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.aps
*.vcproj.*.user
*.vspscc
*_i.c
*.i
*.icf
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.sbr
*.sdf
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
ipch/
*.opensdf
# Ignore files build by ndk and eclipse
libs/
bin/
obj/
gen/
assets/
local.properties
# Ignore files built by NaCl
samples/Cpp/HelloCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/Resources/
samples/Cpp/TestCpp/proj.nacl/out/
samples/Cpp/SimpleGame/proj.nacl/Resources/
samples/Lua/HelloLua/proj.nacl/Resources/
samples/Lua/TestLua/proj.nacl/Resources/
# Ignore python compiled files
*.pyc
# Ignore files build by airplay and marmalade
build_*_xcode/
build_*_vc10/
# Ignore files build by xcode
*.mode*v*
*.pbxuser
*.xcbkptlist
*.xcscheme
*.xcworkspacedata
*.xcuserstate
xcschememanagement.plist
build/
.DS_Store
._.*
xcuserdata/
DerivedData/
# Ignore files built by bada
.Simulator-Debug/
.Target-Debug/
.Target-Release/
# Ignore files built by blackberry
Simulator/
Device-Debug/
Device-Release/
# Ignore vim swaps
*.swp
# Ignore config files in javascript bindings generator
tools/tojs/user.cfg
# ... userconf.ini generated if running from tools/tojs
tools/tojs/userconf.ini
# ... userconf.ini generated if running from tools/jenkins_scripts/mac/android/
tools/jenkins_scripts/mac/android/userconf.ini
# Ignore files built by plugin
publish/*
tools/toolsForPublish/environment.sh
.settings
plugins/china*
plugins/punchbox*
plugins/touchpay*
samplesPrivate*

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +0,0 @@
#ifndef __pluginx_protocols_h__
#define __pluginx_protocols_h__
#include "jsapi.h"
#include "jsfriendapi.h"
extern JSClass *jsb_PluginProtocol_class;
extern JSObject *jsb_PluginProtocol_prototype;
JSBool js_pluginx_protocols_PluginProtocol_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_PluginProtocol_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_PluginProtocol(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_PluginProtocol_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginProtocol_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginProtocol_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginProtocol_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_PluginManager_class;
extern JSObject *jsb_PluginManager_prototype;
JSBool js_pluginx_protocols_PluginManager_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_PluginManager_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_PluginManager(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_PluginManager_unloadPlugin(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginManager_loadPlugin(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginManager_end(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_PluginManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolAnalytics_class;
extern JSObject *jsb_ProtocolAnalytics_prototype;
JSBool js_pluginx_protocols_ProtocolAnalytics_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolAnalytics_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_logError(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_logEvent(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_startSession(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_stopSession(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolIAP_class;
extern JSObject *jsb_ProtocolIAP_prototype;
JSBool js_pluginx_protocols_ProtocolIAP_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolIAP_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolAds_class;
extern JSObject *jsb_ProtocolAds_prototype;
JSBool js_pluginx_protocols_ProtocolAds_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolAds_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolShare_class;
extern JSObject *jsb_ProtocolShare_prototype;
JSBool js_pluginx_protocols_ProtocolShare_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolShare_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolSocial_class;
extern JSObject *jsb_ProtocolSocial_prototype;
JSBool js_pluginx_protocols_ProtocolSocial_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolSocial_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_submitScore(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_unlockAchievement(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolUser_class;
extern JSObject *jsb_ProtocolUser_prototype;
JSBool js_pluginx_protocols_ProtocolUser_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolUser_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolUser_isLogined(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolUser_logout(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolUser_login(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp);
#endif

View File

@ -1,289 +0,0 @@
/**
* @module pluginx_protocols
*/
var plugin = plugin || {};
/**
* @class PluginProtocol
*/
plugin.PluginProtocol = {
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "std::string"
*/
getPluginVersion : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "std::string"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
};
/**
* @class PluginManager
*/
plugin.PluginManager = {
/**
* @method unloadPlugin
* @param {const char*}
*/
unloadPlugin : function () {},
/**
* @method loadPlugin
* @return A value converted from C/C++ "cocos2d::plugin::PluginProtocol*"
* @param {const char*}
*/
loadPlugin : function () {},
/**
* @method end
*/
end : function () {},
/**
* @method getInstance
* @return A value converted from C/C++ "cocos2d::plugin::PluginManager*"
*/
getInstance : function () {},
};
/**
* @class ProtocolAnalytics
*/
plugin.ProtocolAnalytics = {
/**
* @method logTimedEventBegin
* @param {const char*}
*/
logTimedEventBegin : function () {},
/**
* @method logError
* @param {const char*}
* @param {const char*}
*/
logError : function () {},
/**
* @method setCaptureUncaughtException
* @param {bool}
*/
setCaptureUncaughtException : function () {},
/**
* @method setSessionContinueMillis
* @param {long}
*/
setSessionContinueMillis : function () {},
/**
* @method logEvent
* @param {const char*}
* @param {LogEventParamMap*}
*/
logEvent : function () {},
/**
* @method startSession
* @param {const char*}
*/
startSession : function () {},
/**
* @method stopSession
*/
stopSession : function () {},
/**
* @method logTimedEventEnd
* @param {const char*}
*/
logTimedEventEnd : function () {},
};
/**
* @class ProtocolIAP
*/
plugin.ProtocolIAP = {
/**
* @method payForProduct
* @param {TProductInfo}
*/
payForProduct : function () {},
/**
* @method onPayResult
* @param {cocos2d::plugin::PayResultCode}
* @param {const char*}
*/
onPayResult : function () {},
/**
* @method configDeveloperInfo
* @param {TIAPDeveloperInfo}
*/
configDeveloperInfo : function () {},
};
/**
* @class ProtocolAds
*/
plugin.ProtocolAds = {
/**
* @method showAds
* @param {TAdsInfo}
* @param {cocos2d::plugin::ProtocolAds::AdsPos}
*/
showAds : function () {},
/**
* @method hideAds
* @param {TAdsInfo}
*/
hideAds : function () {},
/**
* @method queryPoints
*/
queryPoints : function () {},
/**
* @method spendPoints
* @param {int}
*/
spendPoints : function () {},
/**
* @method configDeveloperInfo
* @param {TAdsDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getAdsListener
* @return A value converted from C/C++ "cocos2d::plugin::AdsListener*"
*/
getAdsListener : function () {},
};
/**
* @class ProtocolShare
*/
plugin.ProtocolShare = {
/**
* @method onShareResult
* @param {cocos2d::plugin::ShareResultCode}
* @param {const char*}
*/
onShareResult : function () {},
/**
* @method share
* @param {TShareInfo}
*/
share : function () {},
/**
* @method configDeveloperInfo
* @param {TShareDeveloperInfo}
*/
configDeveloperInfo : function () {},
};
/**
* @class ProtocolSocial
*/
plugin.ProtocolSocial = {
/**
* @method showLeaderboard
* @param {const char*}
*/
showLeaderboard : function () {},
/**
* @method showAchievements
*/
showAchievements : function () {},
/**
* @method submitScore
* @param {const char*}
* @param {long}
*/
submitScore : function () {},
/**
* @method configDeveloperInfo
* @param {TSocialDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method unlockAchievement
* @param {TAchievementInfo}
*/
unlockAchievement : function () {},
};
/**
* @class ProtocolUser
*/
plugin.ProtocolUser = {
/**
* @method isLogined
* @return A value converted from C/C++ "bool"
*/
isLogined : function () {},
/**
* @method logout
*/
logout : function () {},
/**
* @method configDeveloperInfo
* @param {TUserDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method login
*/
login : function () {},
/**
* @method getSessionID
* @return A value converted from C/C++ "std::string"
*/
getSessionID : function () {},
};

View File

@ -1,50 +0,0 @@
plugin = plugin || {};
plugin.PluginParam.ParamType = {};
plugin.PluginParam.ParamType.TypeInt = 1;
plugin.PluginParam.ParamType.TypeFloat = 2;
plugin.PluginParam.ParamType.TypeBool = 3;
plugin.PluginParam.ParamType.TypeString = 4;
plugin.PluginParam.ParamType.TypeStringMap = 5;
plugin.ProtocolAds.AdsResultCode = {};
plugin.ProtocolAds.AdsResultCode.AdsReceived = 0;
plugin.ProtocolAds.AdsResultCode.FullScreenViewShown = 1;
plugin.ProtocolAds.AdsResultCode.FullScreenViewDismissed = 2;
plugin.ProtocolAds.AdsResultCode.PointsSpendSucceed = 3;
plugin.ProtocolAds.AdsResultCode.PointsSpendFailed = 4;
plugin.ProtocolAds.AdsResultCode.NetworkError = 5;
plugin.ProtocolAds.AdsResultCode.UnknownError = 6;
plugin.ProtocolAds.AdsPos = {};
plugin.ProtocolAds.AdsPos.PosCenter = 0;
plugin.ProtocolAds.AdsPos.PosTop = 1;
plugin.ProtocolAds.AdsPos.PosTopLeft = 2;
plugin.ProtocolAds.AdsPos.PosTopRight = 3;
plugin.ProtocolAds.AdsPos.PosBottom = 4;
plugin.ProtocolAds.AdsPos.PosBottomLeft = 5;
plugin.ProtocolAds.AdsPos.PosBottomRight = 6;
plugin.ProtocolIAP.PayResultCode = {};
plugin.ProtocolIAP.PayResultCode.PaySuccess = 0;
plugin.ProtocolIAP.PayResultCode.PayFail = 1;
plugin.ProtocolIAP.PayResultCode.PayCancel = 2;
plugin.ProtocolIAP.PayResultCode.PayTimeOut = 3;
plugin.ProtocolShare.ShareResultCode = {};
plugin.ProtocolShare.ShareResultCode.ShareSuccess = 0;
plugin.ProtocolShare.ShareResultCode.ShareFail = 1;
plugin.ProtocolShare.ShareResultCode.ShareCancel = 2;
plugin.ProtocolShare.ShareResultCode.ShareTimeOut = 3;
plugin.ProtocolSocial.SocialRetCode = {};
plugin.ProtocolSocial.SocialRetCode.ScoreSubmitSuccess = 1;
plugin.ProtocolSocial.SocialRetCode.ScoreSubmitFailed = 2;
plugin.ProtocolSocial.SocialRetCode.AchUnlockSuccess = 3;
plugin.ProtocolSocial.SocialRetCode.AchUnlockFailed = 4;
plugin.ProtocolUser.UserActionResultCode = {};
plugin.ProtocolUser.UserActionResultCode.LoginSucceed = 0;
plugin.ProtocolUser.UserActionResultCode.LoginFailed = 1;
plugin.ProtocolUser.UserActionResultCode.LogoutSucceed = 2;

View File

@ -1,322 +0,0 @@
#include "jsb_pluginx_basic_conversions.h"
#include <math.h>
#include "jsb_pluginx_spidermonkey_specifics.h"
#include "pluginxUTF8.h"
namespace pluginx {
// just a simple utility to avoid mem leaking when using JSString
class JSStringWrapper
{
JSString* string;
const char* buffer;
JSContext* cx;
public:
JSStringWrapper() {
buffer = NULL;
}
JSStringWrapper(JSString* str, JSContext* cx) {
set(str, cx);
}
JSStringWrapper(jsval val, JSContext* cx) {
set(val, cx);
}
~JSStringWrapper() {
if (buffer) {
// delete[] buffer;
// buffer = NULL;
JS_free(cx, (void*)buffer);
}
}
void set(jsval val, JSContext* cx) {
if (val.isString()) {
this->set(val.toString(), cx);
} else {
buffer = NULL;
}
}
void set(JSString* str, JSContext* cx) {
this->cx = cx;
string = str;
// Not suppored in SpiderMonkey v19
buffer = JS_EncodeString(cx, string);
// const jschar *chars = JS_GetStringCharsZ(cx, string);
// size_t l = JS_GetStringLength(string);
// char* pUTF8Str = cc_utf16_to_utf8((const unsigned short*)chars, l, NULL, NULL);
// buffer = pUTF8Str;
}
std::string get() {
return buffer;
}
operator std::string() {
return std::string(buffer);
}
operator char*() {
return (char*)buffer;
}
};
JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval )
{
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
if (!ok) {
LOGD("jsval_to_int32: the argument is not a number");
return JS_FALSE;
}
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (int32_t)dp;
return ok;
}
JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval )
{
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
if (!ok) {
LOGD("jsval_to_uint32: the argument is not a number");
return JS_FALSE;
}
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (uint32_t)dp;
return ok;
}
JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval )
{
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
if (!ok) {
LOGD("jsval_to_uint16: the argument is not a number");
return JS_FALSE;
}
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (uint16_t)dp;
return ok;
}
JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) {
JSObject *tmp_arg;
JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg );
if (!ok) {
LOGD("jsval_to_long_long: Error converting value to object");
return JS_FALSE;
}
JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object");
JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length");
uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg );
long long ret = arg_array[0];
ret = ret << 32;
ret |= arg_array[1];
*r = ret;
return JS_TRUE;
}
JSBool jsval_to_long(JSContext *cx, jsval vp, long* ret)
{
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
if (!ok) {
LOGD("jsval_to_long: the argument is not a number");
return JS_FALSE;
}
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
*ret = (long)dp;
return ok;
}
JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret) {
JSString *tmp = JS_ValueToString(cx, v);
if (!tmp) {
LOGD("jsval_to_std_string: the jsval is not a string.");
return JS_FALSE;
}
JSStringWrapper str(tmp, cx);
*ret = str.get();
return JS_TRUE;
}
JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret)
{
JSObject* tmp = JSVAL_TO_OBJECT(v);
if (!tmp) {
LOGD("jsval_to_TProductInfo: the jsval is not an object.");
return JS_FALSE;
}
JSObject* it = JS_NewPropertyIterator(cx, tmp);
while (true)
{
jsid idp;
jsval key;
if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key))
return JS_FALSE; // error
if (key == JSVAL_VOID)
break; // end of iteration
if (! JSVAL_IS_STRING(key))
continue; // ignore integer properties
jsval value;
JS_GetPropertyById(cx, tmp, idp, &value);
if (! JSVAL_IS_STRING(value))
continue; // ignore integer properties
JSStringWrapper strWrapper(JSVAL_TO_STRING(key), cx);
JSStringWrapper strWrapper2(JSVAL_TO_STRING(value), cx);
(*ret)[strWrapper.get()] = strWrapper2.get();
LOGD("iterate object: key = %s, value = %s", strWrapper.get().c_str(), strWrapper2.get().c_str());
}
return JS_TRUE;
}
JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map<std::string, std::string>* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TAchievementInfo(JSContext *cx, jsval v, TAchievementInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TUserDeveloperInfo(JSContext *cx, jsval v, TUserDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret)
{
JSBool jsret = JS_FALSE;
if (v.isObject())
{
LogEventParamMap* tmp = new LogEventParamMap();
jsret = jsval_to_TProductInfo(cx, v, tmp);
if (jsret) {
*ret = tmp;
}
}
return jsret;
}
JSBool jsval_to_StringMap(JSContext *cx, jsval v, StringMap* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
// From native type to jsval
jsval int32_to_jsval( JSContext *cx, int32_t number )
{
return INT_TO_JSVAL(number);
}
jsval uint32_to_jsval( JSContext *cx, uint32_t number )
{
return UINT_TO_JSVAL(number);
}
jsval long_long_to_jsval(JSContext* cx, long long v) {
JSObject *tmp = JS_NewUint32Array(cx, 2);
uint32_t *data = (uint32_t *)JS_GetArrayBufferViewData(tmp);
data[0] = ((uint32_t *)(&v))[0];
data[1] = ((uint32_t *)(&v))[1];
return OBJECT_TO_JSVAL(tmp);
}
jsval long_to_jsval(JSContext* cx, long v)
{
return INT_TO_JSVAL(v);
}
jsval std_string_to_jsval(JSContext* cx, std::string& v) {
JSString *str = JS_NewStringCopyZ(cx, v.c_str());
jsval rval;
// unsigned short* pUTF16 = cc_utf8_to_utf16(v.c_str());
// JSString *str = JS_NewUCStringCopyZ(cx, pUTF16);
rval = STRING_TO_JSVAL(str);
// delete[] pUTF16;
return rval;
}
jsval c_string_to_jsval(JSContext* cx, const char* v) {
std::string str(v);
return std_string_to_jsval(cx, str);
}
jsval TProductInfo_to_jsval(JSContext *cx, TProductInfo& ret)
{
JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL);
if (!tmp) return JSVAL_NULL;
for (TProductInfo::iterator it = ret.begin(); it != ret.end(); ++it)
{
JS_DefineProperty(cx, tmp, it->first.c_str(), std_string_to_jsval(cx, it->second), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
}
return OBJECT_TO_JSVAL(tmp);
}
jsval LogEventParamMap_to_jsval(JSContext *cx, LogEventParamMap*& ret)
{// TODO:
return JSVAL_NULL;
}
}// namespace pluginx {

View File

@ -1,54 +0,0 @@
#ifndef __JS_BASIC_CONVERSIONS_H__
#define __JS_BASIC_CONVERSIONS_H__
#include "jsapi.h"
#include "jsfriendapi.h"
#include "ProtocolIAP.h"
#include "ProtocolAnalytics.h"
#include "ProtocolAds.h"
#include "ProtocolShare.h"
#include "ProtocolSocial.h"
#include "ProtocolUser.h"
#ifndef CCLOGINFO
#define CCLOGINFO(...)
#endif
using namespace cocos2d::plugin;
namespace pluginx {
// to native
JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret );
JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret );
JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret );
JSBool jsval_to_long(JSContext *cx, jsval v, long* ret);
JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret);
JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret);
JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret);
JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret);
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret);
JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret);
JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret);
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret);
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret);
JSBool jsval_to_TAchievementInfo(JSContext *cx, jsval v, TAchievementInfo* ret);
JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map<std::string, std::string>* ret);
JSBool jsval_to_TUserDeveloperInfo(JSContext *cx, jsval v, TUserDeveloperInfo* ret);
JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret);
JSBool jsval_to_StringMap(JSContext *cx, jsval v, StringMap* ret);
// from native
jsval int32_to_jsval( JSContext *cx, int32_t l);
jsval uint32_to_jsval( JSContext *cx, uint32_t number );
jsval long_long_to_jsval(JSContext* cx, long long v);
jsval long_to_jsval(JSContext* cx, long v);
jsval std_string_to_jsval(JSContext* cx, std::string& v);
jsval c_string_to_jsval(JSContext* cx, const char* v);
jsval TProductInfo_to_jsval(JSContext *cx, TProductInfo& ret);
jsval LogEventParamMap_to_jsval(JSContext *cx, LogEventParamMap*& ret);
} // namespace pluginx {
#endif /* __JS_BASIC_CONVERSIONS_H__ */

View File

@ -1,47 +0,0 @@
#include "jsb_pluginx_extension_registration.h"
#include "jsb_pluginx_manual_callback.h"
#include "jsb_pluginx_manual_protocols.h"
static jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string) {
jsval out;
if (JS_EvaluateScript(cx, thisObj, string, strlen(string), "(string)", 1, &out) == JS_TRUE) {
return out;
}
return JSVAL_VOID;
}
extern JSObject *jsb_ProtocolIAP_prototype;
extern JSObject *jsb_ProtocolAds_prototype;
extern JSObject *jsb_ProtocolShare_prototype;
extern JSObject *jsb_PluginProtocol_prototype;
extern JSObject *jsb_ProtocolSocial_prototype;
extern JSObject *jsb_ProtocolUser_prototype;
void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
{
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, global, "plugin", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, global, "plugin", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolShare_prototype, "setResultListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolSocial_prototype, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolUser_prototype, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
global = ns;
js_register_pluginx_protocols_PluginParam(cx, global);
}

View File

@ -1,9 +0,0 @@
#ifndef __JS_EXTENSION_REGISTRATION_H__
#define __JS_EXTENSION_REGISTRATION_H__
#include "jsapi.h"
#include "jsfriendapi.h"
void register_pluginx_js_extensions(JSContext* cx, JSObject* global);
#endif /* __JS_EXTENSION_REGISTRATION_H__ */

View File

@ -1,371 +0,0 @@
#include "jsb_pluginx_manual_callback.h"
#include "jsb_pluginx_basic_conversions.h"
#include "jsb_pluginx_spidermonkey_specifics.h"
#include "ProtocolAds.h"
using namespace pluginx;
static JSContext* s_cx = NULL;
class Pluginx_PurchaseResult : public cocos2d::plugin::PayResultListener
{
public:
virtual void onPayResult(cocos2d::plugin::PayResultCode ret, const char* msg, cocos2d::plugin::TProductInfo info)
{
char goodInfo[1024] = { 0 };
sprintf(goodInfo, "商品名称:%s\n商品价格:%s\n商品描述:%s",
info.find("productName")->second.c_str(),
info.find("productPrice")->second.c_str(),
info.find("productDesc")->second.c_str());
LOGD(goodInfo);
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
jsval dataVal[3];
dataVal[0] = INT_TO_JSVAL(ret);
std::string strMsgInfo = msg;
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
dataVal[2] = TProductInfo_to_jsval(cx, info);
JSObject* obj = _JSDelegate;
if (JS_HasProperty(cx, obj, "onPayResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onPayResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onPayResult",
3, dataVal, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
_JSDelegate = pJSDelegate;
}
private:
JSObject* _JSDelegate;
};
JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_PurchaseResult* nativeDelegate = new Pluginx_PurchaseResult();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setResultListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
class Pluginx_AdsListener : public cocos2d::plugin::AdsListener
{
public:
virtual void onAdsResult(AdsResultCode code, const char* msg)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
jsval dataVal[2];
dataVal[0] = INT_TO_JSVAL(code);
std::string strMsgInfo = msg;
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = _JSDelegate;
JSBool bRet = JS_HasProperty(cx, obj, "onAdsResult", &hasAction);
if (bRet && hasAction) {
if(!JS_GetProperty(cx, obj, "onAdsResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onAdsResult",
2, dataVal, &retval);
}
}
virtual void onPlayerGetPoints(ProtocolAds* pAdsPlugin, int points)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
js_proxy_t * p;
JS_GET_PROXY(p, pAdsPlugin);
if (! p) return;
jsval dataVal[2];
jsval arg = OBJECT_TO_JSVAL(p->obj);
dataVal[0] = arg;
dataVal[1] = INT_TO_JSVAL(points);
JSObject* obj = _JSDelegate;
JSBool bRet = JS_HasProperty(cx, obj, "onPlayerGetPoints", &hasAction);
if (bRet && hasAction) {
if(!JS_GetProperty(cx, obj, "onPlayerGetPoints", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onPlayerGetPoints",
2, NULL, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
_JSDelegate = pJSDelegate;
}
private:
JSObject* _JSDelegate;
};
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_AdsListener* nativeDelegate = new Pluginx_AdsListener();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setAdsListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
class Pluginx_ShareResult : public cocos2d::plugin::ShareResultListener
{
public:
virtual void onShareResult(cocos2d::plugin::ShareResultCode ret, const char* msg)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
jsval dataVal[2];
dataVal[0] = INT_TO_JSVAL(ret);
std::string strMsgInfo = msg;
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = _JSDelegate;
if (JS_HasProperty(cx, obj, "onShareResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onShareResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onShareResult",
2, dataVal, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
_JSDelegate = pJSDelegate;
}
private:
JSObject* _JSDelegate;
};
JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_ShareResult* nativeDelegate = new Pluginx_ShareResult();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setResultListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
class Pluginx_SocialResult : public cocos2d::plugin::SocialListener
{
public:
virtual void onSocialResult(cocos2d::plugin::SocialRetCode ret, const char* msg)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
jsval dataVal[2];
dataVal[0] = INT_TO_JSVAL(ret);
std::string strMsgInfo = msg;
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = _JSDelegate;
if (JS_HasProperty(cx, obj, "onSocialResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onSocialResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onSocialResult",
2, dataVal, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
_JSDelegate = pJSDelegate;
}
private:
JSObject* _JSDelegate;
};
JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_SocialResult* nativeDelegate = new Pluginx_SocialResult();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
class Pluginx_UserActionListener : public cocos2d::plugin::UserActionListener
{
public:
virtual void onActionResult(ProtocolUser* userPlugin, cocos2d::plugin::UserActionResultCode ret, const char* msg)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
js_proxy_t * p;
JS_GET_PROXY(p, userPlugin);
if (! p) return;
jsval dataVal[3];
jsval arg1 = OBJECT_TO_JSVAL(p->obj);
dataVal[0] = arg1;
dataVal[1] = INT_TO_JSVAL(ret);
std::string strMsgInfo = msg;
dataVal[2] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = _JSDelegate;
if (JS_HasProperty(cx, obj, "onActionResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onActionResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onActionResult",
3, dataVal, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
_JSDelegate = pJSDelegate;
}
private:
JSObject* _JSDelegate;
};
JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_UserActionListener* nativeDelegate = new Pluginx_UserActionListener();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setActionListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}

View File

@ -1,13 +0,0 @@
#ifndef __JS_MANUAL_CALLBACK_H__
#define __JS_MANUAL_CALLBACK_H__
#include "jsapi.h"
#include "jsfriendapi.h"
JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp);
#endif /* __JS_MANUAL_CALLBACK_H__ */

View File

@ -1,343 +0,0 @@
#include "jsb_pluginx_manual_protocols.h"
#include "jsb_pluginx_basic_conversions.h"
#include "jsb_pluginx_spidermonkey_specifics.h"
#include <string>
#include <vector>
#include "PluginProtocol.h"
using namespace pluginx;
JSClass *jsb_PluginParam_class;
JSObject *jsb_PluginParam_prototype;
JSBool js_pluginx_protocols_PluginParam_constructor(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = NULL;
cocos2d::plugin::PluginParam* cobj = NULL;
do {
if (argc == 2) {
int arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
if (!ok) { ok = JS_TRUE; break; }
switch (arg0)
{
case cocos2d::plugin::PluginParam::kParamTypeInt:
{
int arg1;
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); }
}
break;
case cocos2d::plugin::PluginParam::kParamTypeFloat:
{
double arg1;
ok &= JS_ValueToNumber(cx, argv[1], &arg1);
if (ok) {
float tempArg = arg1;
cobj = new cocos2d::plugin::PluginParam(tempArg);
}
}
break;
case cocos2d::plugin::PluginParam::kParamTypeBool:
{
JSBool arg1;
ok &= JS_ValueToBoolean(cx, argv[1], &arg1);
if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); }
}
break;
case cocos2d::plugin::PluginParam::kParamTypeString:
{
const char* arg1;
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); }
}
break;
case cocos2d::plugin::PluginParam::kParamTypeStringMap:
{
StringMap arg1;
ok &= jsval_to_StringMap(cx, argv[1], &arg1);
if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); }
}
break;
default:
break;
}
if (!ok || NULL == cobj) { ok = JS_TRUE; break; }
TypeTest<cocos2d::plugin::PluginParam> t;
js_type_class_t *typeClass;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass);
assert(typeClass);
obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto);
js_proxy_t *proxy;
JS_NEW_PROXY(proxy, cobj, obj);
}
} while (0);
if (cobj) {
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
void js_pluginx_protocols_PluginParam_finalize(JSFreeOp *fop, JSObject *obj) {
CCLOGINFO("jsbindings: finalizing JS object %p (PluginParam)", obj);
js_proxy_t* nproxy;
js_proxy_t* jsproxy;
JS_GET_NATIVE_PROXY(jsproxy, obj);
if (jsproxy) {
JS_GET_PROXY(nproxy, jsproxy->ptr);
cocos2d::plugin::PluginParam *nobj = static_cast<cocos2d::plugin::PluginParam *>(nproxy->ptr);
if (nobj)
delete nobj;
JS_REMOVE_PROXY(nproxy, jsproxy);
}
}
static JSBool js_pluginx_protocols_PluginParam_ctor(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
cocos2d::plugin::PluginParam *nobj = new cocos2d::plugin::PluginParam();
js_proxy_t* p;
JS_NEW_PROXY(p, nobj, obj);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
void js_register_pluginx_protocols_PluginParam(JSContext *cx, JSObject *global) {
jsb_PluginParam_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_PluginParam_class->name = "PluginParam";
jsb_PluginParam_class->addProperty = JS_PropertyStub;
jsb_PluginParam_class->delProperty = JS_PropertyStub;
jsb_PluginParam_class->getProperty = JS_PropertyStub;
jsb_PluginParam_class->setProperty = JS_StrictPropertyStub;
jsb_PluginParam_class->enumerate = JS_EnumerateStub;
jsb_PluginParam_class->resolve = JS_ResolveStub;
jsb_PluginParam_class->convert = JS_ConvertStub;
jsb_PluginParam_class->finalize = js_pluginx_protocols_PluginParam_finalize;
jsb_PluginParam_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = {
{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
};
JSFunctionSpec *funcs = NULL;
JSFunctionSpec *st_funcs = NULL;
jsb_PluginParam_prototype = JS_InitClass(
cx, global,
NULL, // parent proto
jsb_PluginParam_class,
js_pluginx_protocols_PluginParam_constructor, 0, // constructor
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
JSBool found;
JS_SetPropertyAttributes(cx, global, "PluginParam", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::PluginParam> t;
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId;
p->jsclass = jsb_PluginParam_class;
p->proto = jsb_PluginParam_prototype;
p->parentProto = NULL;
HASH_ADD_INT(_js_global_type_ht, type, p);
}
}
JSBool js_pluginx_PluginProtocol_callFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp)
{
JSBool ok = JS_TRUE;
jsval *argv = JS_ARGV(cx, vp);
if (argc > 0) {
std::string strName;
ok &= jsval_to_std_string(cx, argv[0], &strName);
std::vector<cocos2d::plugin::PluginParam*> params;
uint32_t i = 1;
while (i < argc) {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]);
if (tmpObj == NULL)
break;
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL);
JS_TEST_NATIVE_OBJECT(cx, item)
params.push_back(item);
i++;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
cobj->callFuncWithParam(strName.c_str(), params);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
JSBool js_pluginx_PluginProtocol_callStringFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp)
{
JSBool ok = JS_TRUE;
jsval *argv = JS_ARGV(cx, vp);
if (argc > 0) {
std::string strName;
ok &= jsval_to_std_string(cx, argv[0], &strName);
std::vector<cocos2d::plugin::PluginParam*> params;
uint32_t i = 1;
while (i < argc) {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]);
if (tmpObj == NULL)
break;
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL);
JS_TEST_NATIVE_OBJECT(cx, item)
params.push_back(item);
i++;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
std::string ret = cobj->callStringFuncWithParam(strName.c_str(), params);
jsval jsret;
jsret = std_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
JSBool js_pluginx_PluginProtocol_callIntFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp)
{
JSBool ok = JS_TRUE;
jsval *argv = JS_ARGV(cx, vp);
if (argc > 0) {
std::string strName;
ok &= jsval_to_std_string(cx, argv[0], &strName);
std::vector<cocos2d::plugin::PluginParam*> params;
uint32_t i = 1;
while (i < argc) {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]);
if (tmpObj == NULL)
break;
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL);
JS_TEST_NATIVE_OBJECT(cx, item)
params.push_back(item);
i++;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
int ret = cobj->callIntFuncWithParam(strName.c_str(), params);
jsval jsret;
jsret = int32_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
JSBool js_pluginx_PluginProtocol_callFloatFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp)
{
JSBool ok = JS_TRUE;
jsval *argv = JS_ARGV(cx, vp);
if (argc > 0) {
std::string strName;
ok &= jsval_to_std_string(cx, argv[0], &strName);
std::vector<cocos2d::plugin::PluginParam*> params;
uint32_t i = 1;
while (i < argc) {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]);
if (tmpObj == NULL)
break;
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL);
JS_TEST_NATIVE_OBJECT(cx, item)
params.push_back(item);
i++;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
float ret = cobj->callFloatFuncWithParam(strName.c_str(), params);
jsval jsret;
jsret = DOUBLE_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
JSBool js_pluginx_PluginProtocol_callBoolFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp)
{
JSBool ok = JS_TRUE;
jsval *argv = JS_ARGV(cx, vp);
if (argc > 0) {
std::string strName;
ok &= jsval_to_std_string(cx, argv[0], &strName);
std::vector<cocos2d::plugin::PluginParam*> params;
uint32_t i = 1;
while (i < argc) {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]);
if (tmpObj == NULL)
break;
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL);
JS_TEST_NATIVE_OBJECT(cx, item)
params.push_back(item);
i++;
}
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL);
bool ret = cobj->callBoolFuncWithParam(strName.c_str(), params);
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}

View File

@ -1,22 +0,0 @@
#ifndef __JS_MANUAL_PROTOCOLS_H__
#define __JS_MANUAL_PROTOCOLS_H__
#include "jsapi.h"
#include "jsfriendapi.h"
extern JSClass *jsb_PluginParam_class;
extern JSObject *jsb_PluginParam_prototype;
JSBool js_pluginx_protocols_PluginParam_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_PluginParam_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_PluginParam(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_PluginParam_PluginParam(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_PluginProtocol_callFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_PluginProtocol_callStringFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_PluginProtocol_callIntFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_PluginProtocol_callFloatFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_PluginProtocol_callBoolFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp);
#endif /* __JS_MANUAL_PROTOCOLS_H__ */

View File

@ -1,50 +0,0 @@
#include "jsb_pluginx_spidermonkey_specifics.h"
namespace pluginx {
js_proxy_t *_native_js_global_ht = NULL;
js_proxy_t *_js_native_global_ht = NULL;
js_type_class_t *_js_global_type_ht = NULL;
unsigned int getHashCodeByString(const char *key)
{
unsigned int len = strlen(key);
const char *end=key+len;
unsigned int hash;
for (hash = 0; key < end; key++)
{
hash *= 16777619;
hash ^= (unsigned int) (unsigned char) toupper(*key);
}
return (hash);
}
js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj)
{
js_proxy_t* p;
JS_NEW_PROXY(p, nativeObj, jsObj);
return p;
}
js_proxy_t* jsb_get_native_proxy(void* nativeObj)
{
js_proxy_t* p;
JS_GET_PROXY(p, nativeObj);
return p;
}
js_proxy_t* jsb_get_js_proxy(JSObject* jsObj)
{
js_proxy_t* p;
JS_GET_NATIVE_PROXY(p, jsObj);
return p;
}
void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy)
{
JS_REMOVE_PROXY(nativeProxy, jsProxy);
}
} // namespace pluginx {

View File

@ -1,199 +0,0 @@
#ifndef __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__
#define __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__
#include <typeinfo>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include "jsapi.h"
#include "uthash.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#define PLUGINX_JSB_DEBUG 0
namespace pluginx {
#if PLUGINX_JSB_DEBUG
#ifdef ANDROID
#define LOG_TAG "jsb_pluginx"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#else
#define LOGD(...) printf(__VA_ARGS__)
#endif
#else
#define LOGD(...) do {} while (0)
#endif
#define JSB_PRECONDITION( condition, ...) do { \
if( ! (condition) ) { \
LOGD("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \
LOGD(__VA_ARGS__); \
JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \
if( ! JS_IsExceptionPending( globalContext ) ) { \
JS_ReportError( globalContext, __VA_ARGS__ ); \
} \
return JS_FALSE; \
} \
} while(0)
#define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \
if( ! (condition) ) { \
LOGD("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \
LOGD(__VA_ARGS__); \
if( ! JS_IsExceptionPending( context ) ) { \
JS_ReportError( context, __VA_ARGS__ ); \
} \
return ret_value; \
} \
} while(0)
typedef struct js_proxy {
void *ptr;
JSObject *obj;
UT_hash_handle hh;
} js_proxy_t;
extern js_proxy_t *_native_js_global_ht;
extern js_proxy_t *_js_native_global_ht;
typedef struct js_type_class {
uint32_t type;
JSClass *jsclass;
JSObject *proto;
JSObject *parentProto;
UT_hash_handle hh;
} js_type_class_t;
extern js_type_class_t *_js_global_type_ht;
unsigned int getHashCodeByString(const char *key);
template< typename DERIVED >
class TypeTest
{
public:
static int s_id()
{
// return id unique for DERIVED
// NOT SURE IT WILL BE REALLY UNIQUE FOR EACH CLASS!!
/* Commented by James Chen
Using 'getHashCodeByString(typeid(*native_obj).name())' instead of 'reinterpret_cast<long>(typeid(*native_obj).name());'.
Since on win32 platform, 'reinterpret_cast<long>(typeid(*native_obj).name());' invoking in cocos2d.dll and outside cocos2d.dll(in TestJavascript.exe) will return different address.
But the return string from typeid(*native_obj).name() is the same string, so we must convert the string to hash id to make sure we can get unique id.
*/
// static const long id = reinterpret_cast<long>(typeid( DERIVED ).name());
static const long id = getHashCodeByString(typeid( DERIVED ).name());
return id;
}
static const char* s_name()
{
// return id unique for DERIVED
// ALWAYS VALID BUT STRING, NOT INT - BUT VALID AND CROSS-PLATFORM/CROSS-VERSION COMPATBLE
// AS FAR AS YOU KEEP THE CLASS NAME
return typeid( DERIVED ).name();
}
};
#define JS_NEW_PROXY(p, native_obj, js_obj) \
do { \
p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \
assert(p); \
js_proxy_t* native_obj##js_obj##tmp = NULL; \
HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \
assert(!native_obj##js_obj##tmp); \
p->ptr = native_obj; \
p->obj = js_obj; \
HASH_ADD_PTR(_native_js_global_ht, ptr, p); \
p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \
assert(p); \
native_obj##js_obj##tmp = NULL; \
HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \
assert(!native_obj##js_obj##tmp); \
p->ptr = native_obj; \
p->obj = js_obj; \
HASH_ADD_PTR(_js_native_global_ht, obj, p); \
} while(0) \
#define JS_GET_PROXY(p, native_obj) \
do { \
HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \
} while (0)
#define JS_GET_NATIVE_PROXY(p, js_obj) \
do { \
HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \
} while (0)
#define JS_REMOVE_PROXY(nproxy, jsproxy) \
do { \
if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \
if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \
} while (0)
#define JS_TEST_NATIVE_OBJECT(cx, native_obj) \
if (!native_obj) { \
JS_ReportError(cx, "Invalid Native Object"); \
return JS_FALSE; \
}
js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj);
js_proxy_t* jsb_get_native_proxy(void* nativeObj);
js_proxy_t* jsb_get_js_proxy(JSObject* jsObj);
void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy);
/**
* You don't need to manage the returned pointer. They live for the whole life of
* the app.
*/
template <class T>
inline js_type_class_t *js_get_type_from_native(T* native_obj) {
js_type_class_t *typeProxy;
long typeId = getHashCodeByString(typeid(*native_obj).name());
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
if (!typeProxy) {
typeId = getHashCodeByString(typeid(T).name());
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
}
return typeProxy;
}
/**
* The returned pointer should be deleted using JS_REMOVE_PROXY. Most of the
* time you do that in the C++ destructor.
*/
template<class T>
inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) {
js_proxy_t *proxy;
HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy);
if (!proxy) {
js_type_class_t *typeProxy = js_get_type_from_native<T>(native_obj);
assert(typeProxy);
JSObject* js_obj = JS_NewObject(cx, typeProxy->jsclass, typeProxy->proto, typeProxy->parentProto);
JS_NEW_PROXY(proxy, native_obj, js_obj);
//#ifdef COCOS2D_JAVASCRIPT
// #ifdef DEBUG
// JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name());
// #else
// JS_AddObjectRoot(cx, &proxy->obj);
// #endif
//#endif
return proxy;
} else {
return proxy;
}
return NULL;
}
} // namespace pluginx {
#endif /* __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__ */

View File

@ -1,534 +0,0 @@
/*
* This file uses some implementations of gutf8.c in glib.
*
* gutf8.c - Operations on UTF-8 strings.
*
* Copyright (C) 1999 Tom Tromey
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "pluginxUTF8.h"
namespace pluginx {
#define CCLOGERROR(...) do {} while(0)
#ifndef NULL
#define NULL 0
#endif
int cc_wcslen(const unsigned short* str)
{
int i=0;
while(*str++) i++;
return i;
}
/* Code from GLIB gutf8.c starts here. */
#define UTF8_COMPUTE(Char, Mask, Len) \
if (Char < 128) \
{ \
Len = 1; \
Mask = 0x7f; \
} \
else if ((Char & 0xe0) == 0xc0) \
{ \
Len = 2; \
Mask = 0x1f; \
} \
else if ((Char & 0xf0) == 0xe0) \
{ \
Len = 3; \
Mask = 0x0f; \
} \
else if ((Char & 0xf8) == 0xf0) \
{ \
Len = 4; \
Mask = 0x07; \
} \
else if ((Char & 0xfc) == 0xf8) \
{ \
Len = 5; \
Mask = 0x03; \
} \
else if ((Char & 0xfe) == 0xfc) \
{ \
Len = 6; \
Mask = 0x01; \
} \
else \
Len = -1;
#define UTF8_LENGTH(Char) \
((Char) < 0x80 ? 1 : \
((Char) < 0x800 ? 2 : \
((Char) < 0x10000 ? 3 : \
((Char) < 0x200000 ? 4 : \
((Char) < 0x4000000 ? 5 : 6)))))
#define UTF8_GET(Result, Chars, Count, Mask, Len) \
(Result) = (Chars)[0] & (Mask); \
for ((Count) = 1; (Count) < (Len); ++(Count)) \
{ \
if (((Chars)[(Count)] & 0xc0) != 0x80) \
{ \
(Result) = -1; \
break; \
} \
(Result) <<= 6; \
(Result) |= ((Chars)[(Count)] & 0x3f); \
}
#define UNICODE_VALID(Char) \
((Char) < 0x110000 && \
(((Char) & 0xFFFFF800) != 0xD800) && \
((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
((Char) & 0xFFFE) != 0xFFFE)
static const char utf8_skip_data[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5,
5, 5, 5, 6, 6, 1, 1
};
static const char *const g_utf8_skip = utf8_skip_data;
#define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)])
/*
* @str: the string to search through.
* @c: the character to find.
*
* Returns the index of the first occurrence of the character, if found. Otherwise -1 is returned.
*
* Return value: the index of the first occurrence of the character if found or -1 otherwise.
* */
static unsigned int cc_utf8_find_char(std::vector<unsigned short> str, unsigned short c)
{
unsigned int len = str.size();
for (unsigned int i = 0; i < len; ++i)
if (str[i] == c) return i;
return -1;
}
/*
* @str: the string to search through.
* @c: the character to not look for.
*
* Return value: the index of the last character that is not c.
* */
unsigned int cc_utf8_find_last_not_char(std::vector<unsigned short> str, unsigned short c)
{
int len = str.size();
int i = len - 1;
for (; i >= 0; --i)
if (str[i] != c) return i;
return i;
}
/*
* @str: the string to trim
* @index: the index to start trimming from.
*
* Trims str st str=[0, index) after the operation.
*
* Return value: the trimmed string.
* */
static void cc_utf8_trim_from(std::vector<unsigned short>* str, int index)
{
int size = str->size();
if (index >= size || index < 0)
return;
str->erase(str->begin() + index, str->begin() + size);
}
/*
* @ch is the unicode character whitespace?
*
* Reference: http://en.wikipedia.org/wiki/Whitespace_character#Unicode
*
* Return value: weather the character is a whitespace character.
* */
bool isspace_unicode(unsigned short ch)
{
return (ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 || ch == 0x0085 || ch == 0x00A0 || ch == 0x1680
|| (ch >= 0x2000 && ch <= 0x200A) || ch == 0x2028 || ch == 0x2029 || ch == 0x202F
|| ch == 0x205F || ch == 0x3000;
}
void cc_utf8_trim_ws(std::vector<unsigned short>* str)
{
int len = str->size();
if ( len <= 0 )
return;
int last_index = len - 1;
// Only start trimming if the last character is whitespace..
if (isspace_unicode((*str)[last_index]))
{
for (int i = last_index - 1; i >= 0; --i)
{
if (isspace_unicode((*str)[i]))
last_index = i;
else
break;
}
cc_utf8_trim_from(str, last_index);
}
}
/*
* cc_utf8_strlen:
* @p: pointer to the start of a UTF-8 encoded string.
* @max: the maximum number of bytes to examine. If @max
* is less than 0, then the string is assumed to be
* null-terminated. If @max is 0, @p will not be examined and
* may be %NULL.
*
* Returns the length of the string in characters.
*
* Return value: the length of the string in characters
**/
long
cc_utf8_strlen (const char * p, int max)
{
long len = 0;
const char *start = p;
if (!(p != NULL || max == 0))
{
return 0;
}
if (max < 0)
{
while (*p)
{
p = cc_utf8_next_char (p);
++len;
}
}
else
{
if (max == 0 || !*p)
return 0;
p = cc_utf8_next_char (p);
while (p - start < max && *p)
{
++len;
p = cc_utf8_next_char (p);
}
/* only do the last len increment if we got a complete
* char (don't count partial chars)
*/
if (p - start == max)
++len;
}
return len;
}
/*
* g_utf8_get_char:
* @p: a pointer to Unicode character encoded as UTF-8
*
* Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
* If @p does not point to a valid UTF-8 encoded character, results are
* undefined. If you are not sure that the bytes are complete
* valid Unicode characters, you should use g_utf8_get_char_validated()
* instead.
*
* Return value: the resulting character
**/
static unsigned int
cc_utf8_get_char (const char * p)
{
int i, mask = 0, len;
unsigned int result;
unsigned char c = (unsigned char) *p;
UTF8_COMPUTE (c, mask, len);
if (len == -1)
return (unsigned int) - 1;
UTF8_GET (result, p, i, mask, len);
return result;
}
unsigned short* cc_utf8_to_utf16(const char* str_old)
{
int len = cc_utf8_strlen(str_old, -1);
unsigned short* str_new = new unsigned short[len + 1];
str_new[len] = 0;
for (int i = 0; i < len; ++i)
{
str_new[i] = cc_utf8_get_char(str_old);
str_old = cc_utf8_next_char(str_old);
}
return str_new;
}
std::vector<unsigned short> cc_utf16_vec_from_utf16_str(const unsigned short* str)
{
int len = cc_wcslen(str);
std::vector<unsigned short> str_new;
for (int i = 0; i < len; ++i)
{
str_new.push_back(str[i]);
}
return str_new;
}
/**
* cc_unichar_to_utf8:
* @c: a ISO10646 character code
* @outbuf: output buffer, must have at least 6 bytes of space.
* If %NULL, the length will be computed and returned
* and nothing will be written to @outbuf.
*
* Converts a single character to UTF-8.
*
* Return value: number of bytes written
**/
int
cc_unichar_to_utf8 (unsigned short c,
char *outbuf)
{
unsigned int len = 0;
int first;
int i;
if (c < 0x80)
{
first = 0;
len = 1;
}
else if (c < 0x800)
{
first = 0xc0;
len = 2;
}
else if (c < 0x10000)
{
first = 0xe0;
len = 3;
}
else if (c < 0x200000)
{
first = 0xf0;
len = 4;
}
else if (c < 0x4000000)
{
first = 0xf8;
len = 5;
}
else
{
first = 0xfc;
len = 6;
}
if (outbuf)
{
for (i = len - 1; i > 0; --i)
{
outbuf[i] = (c & 0x3f) | 0x80;
c >>= 6;
}
outbuf[0] = c | first;
}
return len;
}
#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
/**
* cc_utf16_to_utf8:
* @str: a UTF-16 encoded string
* @len: the maximum length of @str to use. If @len < 0, then
* the string is terminated with a 0 character.
* @items_read: location to store number of words read, or %NULL.
* If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
* returned in case @str contains a trailing partial
* character. If an error occurs then the index of the
* invalid input is stored here.
* @items_written: location to store number of bytes written, or %NULL.
* The value stored here does not include the trailing
* 0 byte.
* @error: location to store the error occuring, or %NULL to ignore
* errors. Any of the errors in #GConvertError other than
* %G_CONVERT_ERROR_NO_CONVERSION may occur.
*
* Convert a string from UTF-16 to UTF-8. The result will be
* terminated with a 0 byte.
*
* Return value: a pointer to a newly allocated UTF-8 string.
* This value must be freed with free(). If an
* error occurs, %NULL will be returned and
* @error set.
**/
char *
cc_utf16_to_utf8 (const unsigned short *str,
long len,
long *items_read,
long *items_written)
{
/* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
* are marked.
*/
const unsigned short *in;
char *out;
char *result = NULL;
int n_bytes;
unsigned short high_surrogate;
if (str == 0) return NULL;
n_bytes = 0;
in = str;
high_surrogate = 0;
while ((len < 0 || in - str < len) && *in)
{
unsigned short c = *in;
unsigned short wc;
if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
{
if (high_surrogate)
{
wc = SURROGATE_VALUE (high_surrogate, c);
high_surrogate = 0;
}
else
{
CCLOGERROR("Invalid sequence in conversion input");
goto err_out;
}
}
else
{
if (high_surrogate)
{
CCLOGERROR("Invalid sequence in conversion input");
goto err_out;
}
if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
{
high_surrogate = c;
goto next1;
}
else
wc = c;
}
/********** DIFFERENT for UTF8/UCS4 **********/
n_bytes += UTF8_LENGTH (wc);
next1:
in++;
}
if (high_surrogate && !items_read)
{
CCLOGERROR("Partial character sequence at end of input");
goto err_out;
}
/* At this point, everything is valid, and we just need to convert
*/
/********** DIFFERENT for UTF8/UCS4 **********/
result = new char[n_bytes + 1];
high_surrogate = 0;
out = result;
in = str;
while (out < result + n_bytes)
{
unsigned short c = *in;
unsigned short wc;
if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
{
wc = SURROGATE_VALUE (high_surrogate, c);
high_surrogate = 0;
}
else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
{
high_surrogate = c;
goto next2;
}
else
wc = c;
/********** DIFFERENT for UTF8/UCS4 **********/
out += cc_unichar_to_utf8 (wc, out);
next2:
in++;
}
/********** DIFFERENT for UTF8/UCS4 **********/
*out = '\0';
if (items_written)
/********** DIFFERENT for UTF8/UCS4 **********/
*items_written = out - result;
err_out:
if (items_read)
*items_read = in - str;
return result;
}
}// namespace pluginx {

View File

@ -1,96 +0,0 @@
//
// ccUTF8.h
// cocos2dx
//
// Created by James Chen on 2/27/13.
//
#ifndef __pluginx__ccUTF8__
#define __pluginx__ccUTF8__
#include <vector>
namespace pluginx {
int cc_wcslen(const unsigned short* str);
void cc_utf8_trim_ws(std::vector<unsigned short>* str);
/*
* @ch is the unicode character whitespace?
*
* Reference: http://en.wikipedia.org/wiki/Whitespace_character#Unicode
*
* Return value: weather the character is a whitespace character.
* */
bool isspace_unicode(unsigned short ch);
/*
* cc_utf8_strlen:
* @p: pointer to the start of a UTF-8 encoded string.
* @max: the maximum number of bytes to examine. If @max
* is less than 0, then the string is assumed to be
* null-terminated. If @max is 0, @p will not be examined and
* may be %NULL.
*
* Returns the length of the string in characters.
*
* Return value: the length of the string in characters
**/
long
cc_utf8_strlen (const char * p, int max);
/*
* @str: the string to search through.
* @c: the character to not look for.
*
* Return value: the index of the last character that is not c.
* */
unsigned int cc_utf8_find_last_not_char(std::vector<unsigned short> str, unsigned short c);
std::vector<unsigned short> cc_utf16_vec_from_utf16_str(const unsigned short* str);
/*
* cc_utf8_to_utf16:
* @str_old: pointer to the start of a C string.
*
* Creates a utf8 string from a cstring.
*
* Return value: the newly created utf8 string.
* */
unsigned short* cc_utf8_to_utf16(const char* str_old);
/**
* cc_utf16_to_utf8:
* @str: a UTF-16 encoded string
* @len: the maximum length of @str to use. If @len < 0, then
* the string is terminated with a 0 character.
* @items_read: location to store number of words read, or %NULL.
* If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
* returned in case @str contains a trailing partial
* character. If an error occurs then the index of the
* invalid input is stored here.
* @items_written: location to store number of bytes written, or %NULL.
* The value stored here does not include the trailing
* 0 byte.
* @error: location to store the error occuring, or %NULL to ignore
* errors. Any of the errors in #GConvertError other than
* %G_CONVERT_ERROR_NO_CONVERSION may occur.
*
* Convert a string from UTF-16 to UTF-8. The result will be
* terminated with a 0 byte.
*
* Return value: a pointer to a newly allocated UTF-8 string.
* This value must be freed with free(). If an
* error occurs, %NULL will be returned and
* @error set.
**/
char *
cc_utf16_to_utf8 (const unsigned short *str,
long len,
long *items_read,
long *items_written);
} // namespace pluginx {
#endif /* defined(__cocos2dx__ccUTF8__) */

View File

@ -1,985 +0,0 @@
/*
Copyright (c) 2003-2010, Troy D. Hanson http://uthash.sourceforge.net
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SUPPORT_DATA_SUPPORT_UTHASH_H__
#define __SUPPORT_DATA_SUPPORT_UTHASH_H__
#include <string.h> /* memcmp,strlen */
#include <stddef.h> /* ptrdiff_t */
#include <stdlib.h> /* exit() */
/* These macros use decltype or the earlier __typeof GNU extension.
As decltype is only available in newer compilers (VS2010 or gcc 4.3+
when compiling c++ source) this code uses whatever method is needed
or, for VS2008 where neither is available, uses casting workarounds. */
#ifdef _MSC_VER /* MS compiler */
#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */
#define DECLTYPE(x) (decltype(x))
#else /* VS2008 or older (or VS2010 in C mode) */
#define NO_DECLTYPE
#define DECLTYPE(x)
#endif
#else /* GNU, Sun and other compilers */
#define DECLTYPE(x) (__typeof(x))
#endif
#ifdef ANDROID
#define NO_DECLTYPE
#undef DECLTYPE
#define DECLTYPE(x)
#endif
#ifdef NO_DECLTYPE
#define DECLTYPE_ASSIGN(dst,src) \
do { \
char **_da_dst = (char**)(&(dst)); \
*_da_dst = (char*)(src); \
} while(0)
#else
#define DECLTYPE_ASSIGN(dst,src) \
do { \
(dst) = DECLTYPE(dst)(src); \
} while(0)
#endif
/* uint32_t next definded will conflict with other libraries and an "error C2872: 'uint32_t' : ambiguous symbol" will appear.
so we replace all uint32_t with 'unsigned int'.
*/
/* a number of the hash function use uint32_t which isn't defined on win32 */
// #ifdef _MSC_VER
// typedef unsigned int uint32_t;
// #else
// #ifndef __QNX__
// #include <inttypes.h> /* uint32_t */
// #endif /* __QNX__ */
// #endif /* _MSC_VER */
#define UTHASH_VERSION 1.9.3
#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */
#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
#define uthash_free(ptr,sz) free(ptr) /* free fcn */
#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */
#define uthash_expand_fyi(tbl) /* can be defined to log expands */
/* initial number of buckets */
#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */
#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */
#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */
/* calculate the element whose hash handle address is hhe */
#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
#define HASH_FIND(hh,head,keyptr,keylen,out) \
do { \
unsigned _hf_bkt,_hf_hashv; \
out=NULL; \
if (head) { \
HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
keyptr,keylen,out); \
} \
} \
} while (0)
#ifdef HASH_BLOOM
#define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM)
#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0)
#define HASH_BLOOM_MAKE(tbl) \
do { \
(tbl)->bloom_nbits = HASH_BLOOM; \
(tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \
if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \
memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \
(tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \
} while (0);
#define HASH_BLOOM_FREE(tbl) \
do { \
uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
} while (0);
#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8)))
#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8)))
#define HASH_BLOOM_ADD(tbl,hashv) \
HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (unsigned int)((1ULL << (tbl)->bloom_nbits) - 1)))
#define HASH_BLOOM_TEST(tbl,hashv) \
HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (unsigned int)((1ULL << (tbl)->bloom_nbits) - 1)))
#else
#define HASH_BLOOM_MAKE(tbl)
#define HASH_BLOOM_FREE(tbl)
#define HASH_BLOOM_ADD(tbl,hashv)
#define HASH_BLOOM_TEST(tbl,hashv) (1)
#endif
#define HASH_MAKE_TABLE(hh,head) \
do { \
(head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
sizeof(UT_hash_table)); \
if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
(head)->hh.tbl->tail = &((head)->hh); \
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
(head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
(head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
memset((head)->hh.tbl->buckets, 0, \
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
HASH_BLOOM_MAKE((head)->hh.tbl); \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
} while(0)
#define HASH_ADD(hh,head,fieldname,keylen_in,add) \
HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add)
#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \
do { \
unsigned _ha_bkt; \
(add)->hh.next = NULL; \
(add)->hh.key = (char*)keyptr; \
(add)->hh.keylen = keylen_in; \
if (!(head)) { \
head = (add); \
(head)->hh.prev = NULL; \
HASH_MAKE_TABLE(hh,head); \
} else { \
(head)->hh.tbl->tail->next = (add); \
(add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
(head)->hh.tbl->tail = &((add)->hh); \
} \
(head)->hh.tbl->num_items++; \
(add)->hh.tbl = (head)->hh.tbl; \
HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
(add)->hh.hashv, _ha_bkt); \
HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
HASH_FSCK(hh,head); \
} while(0)
#define HASH_TO_BKT( hashv, num_bkts, bkt ) \
do { \
bkt = ((hashv) & ((num_bkts) - 1)); \
} while(0)
/* delete "delptr" from the hash table.
* "the usual" patch-up process for the app-order doubly-linked-list.
* The use of _hd_hh_del below deserves special explanation.
* These used to be expressed using (delptr) but that led to a bug
* if someone used the same symbol for the head and deletee, like
* HASH_DELETE(hh,users,users);
* We want that to work, but by changing the head (users) below
* we were forfeiting our ability to further refer to the deletee (users)
* in the patch-up process. Solution: use scratch space to
* copy the deletee pointer, then the latter references are via that
* scratch pointer rather than through the repointed (users) symbol.
*/
#define HASH_DELETE(hh,head,delptr) \
do { \
unsigned _hd_bkt; \
struct UT_hash_handle *_hd_hh_del; \
if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
head = NULL; \
} else { \
_hd_hh_del = &((delptr)->hh); \
if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
(head)->hh.tbl->tail = \
(UT_hash_handle*)((char*)((delptr)->hh.prev) + \
(head)->hh.tbl->hho); \
} \
if ((delptr)->hh.prev) { \
((UT_hash_handle*)((char*)((delptr)->hh.prev) + \
(head)->hh.tbl->hho))->next = (delptr)->hh.next; \
} else { \
DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
} \
if (_hd_hh_del->next) { \
((UT_hash_handle*)((char*)_hd_hh_del->next + \
(head)->hh.tbl->hho))->prev = \
_hd_hh_del->prev; \
} \
HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
(head)->hh.tbl->num_items--; \
} \
HASH_FSCK(hh,head); \
} while (0)
/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */
#define HASH_FIND_STR(head,findstr,out) \
HASH_FIND(hh,head,findstr,strlen(findstr),out)
#define HASH_ADD_STR(head,strfield,add) \
HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
#define HASH_FIND_INT(head,findint,out) \
HASH_FIND(hh,head,findint,sizeof(int),out)
#define HASH_ADD_INT(head,intfield,add) \
HASH_ADD(hh,head,intfield,sizeof(int),add)
#define HASH_FIND_PTR(head,findptr,out) \
HASH_FIND(hh,head,findptr,sizeof(void *),out)
#define HASH_ADD_PTR(head,ptrfield,add) \
HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
#define HASH_DEL(head,delptr) \
HASH_DELETE(hh,head,delptr)
/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined.
* This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined.
*/
#ifdef HASH_DEBUG
#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)
#define HASH_FSCK(hh,head) \
do { \
unsigned _bkt_i; \
unsigned _count, _bkt_count; \
char *_prev; \
struct UT_hash_handle *_thh; \
if (head) { \
_count = 0; \
for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
_bkt_count = 0; \
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
_prev = NULL; \
while (_thh) { \
if (_prev != (char*)(_thh->hh_prev)) { \
HASH_OOPS("invalid hh_prev %p, actual %p\n", \
_thh->hh_prev, _prev ); \
} \
_bkt_count++; \
_prev = (char*)(_thh); \
_thh = _thh->hh_next; \
} \
_count += _bkt_count; \
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
HASH_OOPS("invalid bucket count %d, actual %d\n", \
(head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
} \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("invalid hh item count %d, actual %d\n", \
(head)->hh.tbl->num_items, _count ); \
} \
/* traverse hh in app order; check next/prev integrity, count */ \
_count = 0; \
_prev = NULL; \
_thh = &(head)->hh; \
while (_thh) { \
_count++; \
if (_prev !=(char*)(_thh->prev)) { \
HASH_OOPS("invalid prev %p, actual %p\n", \
_thh->prev, _prev ); \
} \
_prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
_thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \
(head)->hh.tbl->hho) : NULL ); \
} \
if (_count != (head)->hh.tbl->num_items) { \
HASH_OOPS("invalid app item count %d, actual %d\n", \
(head)->hh.tbl->num_items, _count ); \
} \
} \
} while (0)
#else
#define HASH_FSCK(hh,head)
#endif
/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to
* the descriptor to which this macro is defined for tuning the hash function.
* The app can #include <unistd.h> to get the prototype for write(2). */
#ifdef HASH_EMIT_KEYS
#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \
do { \
unsigned _klen = fieldlen; \
write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \
write(HASH_EMIT_KEYS, keyptr, fieldlen); \
} while (0)
#else
#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
#endif
/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
#ifdef HASH_FUNCTION
#define HASH_FCN HASH_FUNCTION
#else
#define HASH_FCN HASH_JEN
#endif
/* The Bernstein hash function, used in Perl prior to v5.6 */
#define HASH_BER(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _hb_keylen=keylen; \
char *_hb_key=(char*)(key); \
(hashv) = 0; \
while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \
bkt = (hashv) & (num_bkts-1); \
} while (0)
/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at
* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */
#define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _sx_i; \
char *_hs_key=(char*)(key); \
hashv = 0; \
for(_sx_i=0; _sx_i < keylen; _sx_i++) \
hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
bkt = hashv & (num_bkts-1); \
} while (0)
#define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _fn_i; \
char *_hf_key=(char*)(key); \
hashv = 2166136261UL; \
for(_fn_i=0; _fn_i < keylen; _fn_i++) \
hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \
bkt = hashv & (num_bkts-1); \
} while(0);
#define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _ho_i; \
char *_ho_key=(char*)(key); \
hashv = 0; \
for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
hashv += _ho_key[_ho_i]; \
hashv += (hashv << 10); \
hashv ^= (hashv >> 6); \
} \
hashv += (hashv << 3); \
hashv ^= (hashv >> 11); \
hashv += (hashv << 15); \
bkt = hashv & (num_bkts-1); \
} while(0)
#define HASH_JEN_MIX(a,b,c) \
do { \
a -= b; a -= c; a ^= ( c >> 13 ); \
b -= c; b -= a; b ^= ( a << 8 ); \
c -= a; c -= b; c ^= ( b >> 13 ); \
a -= b; a -= c; a ^= ( c >> 12 ); \
b -= c; b -= a; b ^= ( a << 16 ); \
c -= a; c -= b; c ^= ( b >> 5 ); \
a -= b; a -= c; a ^= ( c >> 3 ); \
b -= c; b -= a; b ^= ( a << 10 ); \
c -= a; c -= b; c ^= ( b >> 15 ); \
} while (0)
#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _hj_i,_hj_j,_hj_k; \
char *_hj_key=(char*)(key); \
hashv = 0xfeedbeef; \
_hj_i = _hj_j = 0x9e3779b9; \
_hj_k = keylen; \
while (_hj_k >= 12) { \
_hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \
+ ( (unsigned)_hj_key[2] << 16 ) \
+ ( (unsigned)_hj_key[3] << 24 ) ); \
_hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \
+ ( (unsigned)_hj_key[6] << 16 ) \
+ ( (unsigned)_hj_key[7] << 24 ) ); \
hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \
+ ( (unsigned)_hj_key[10] << 16 ) \
+ ( (unsigned)_hj_key[11] << 24 ) ); \
\
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
\
_hj_key += 12; \
_hj_k -= 12; \
} \
hashv += keylen; \
switch ( _hj_k ) { \
case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \
case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \
case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \
case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \
case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \
case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \
case 5: _hj_j += _hj_key[4]; \
case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \
case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \
case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \
case 1: _hj_i += _hj_key[0]; \
} \
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
bkt = hashv & (num_bkts-1); \
} while(0)
/* The Paul Hsieh hash function */
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
#define get16bits(d) (*((const uint16_t *) (d)))
#endif
#if !defined (get16bits)
#define get16bits(d) ((((unsigned int)(((const uint8_t *)(d))[1])) << 8) \
+(unsigned int)(((const uint8_t *)(d))[0]) )
#endif
#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \
do { \
char *_sfh_key=(char*)(key); \
unsigned int _sfh_tmp, _sfh_len = keylen; \
\
int _sfh_rem = _sfh_len & 3; \
_sfh_len >>= 2; \
hashv = 0xcafebabe; \
\
/* Main loop */ \
for (;_sfh_len > 0; _sfh_len--) { \
hashv += get16bits (_sfh_key); \
_sfh_tmp = (get16bits (_sfh_key+2) << 11) ^ hashv; \
hashv = (hashv << 16) ^ _sfh_tmp; \
_sfh_key += 2*sizeof (uint16_t); \
hashv += hashv >> 11; \
} \
\
/* Handle end cases */ \
switch (_sfh_rem) { \
case 3: hashv += get16bits (_sfh_key); \
hashv ^= hashv << 16; \
hashv ^= _sfh_key[sizeof (uint16_t)] << 18; \
hashv += hashv >> 11; \
break; \
case 2: hashv += get16bits (_sfh_key); \
hashv ^= hashv << 11; \
hashv += hashv >> 17; \
break; \
case 1: hashv += *_sfh_key; \
hashv ^= hashv << 10; \
hashv += hashv >> 1; \
} \
\
/* Force "avalanching" of final 127 bits */ \
hashv ^= hashv << 3; \
hashv += hashv >> 5; \
hashv ^= hashv << 4; \
hashv += hashv >> 17; \
hashv ^= hashv << 25; \
hashv += hashv >> 6; \
bkt = hashv & (num_bkts-1); \
} while(0);
#ifdef HASH_USING_NO_STRICT_ALIASING
/* The MurmurHash exploits some CPU's (e.g. x86) tolerance for unaligned reads.
* For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error.
* So MurmurHash comes in two versions, the faster unaligned one and the slower
* aligned one. We only use the faster one on CPU's where we know it's safe.
*
* Note the preprocessor built-in defines can be emitted using:
*
* gcc -m64 -dM -E - < /dev/null (on gcc)
* cc -## a.c (where a.c is a simple test file) (Sun Studio)
*/
#if (defined(__i386__) || defined(__x86_64__))
#define HASH_MUR HASH_MUR_UNALIGNED
#else
#define HASH_MUR HASH_MUR_ALIGNED
#endif
/* Appleby's MurmurHash fast version for unaligned-tolerant archs like i386 */
#define HASH_MUR_UNALIGNED(key,keylen,num_bkts,hashv,bkt) \
do { \
const unsigned int _mur_m = 0x5bd1e995; \
const int _mur_r = 24; \
hashv = 0xcafebabe ^ keylen; \
char *_mur_key = (char *)(key); \
unsigned int _mur_tmp, _mur_len = keylen; \
\
for (;_mur_len >= 4; _mur_len-=4) { \
_mur_tmp = *(unsigned int *)_mur_key; \
_mur_tmp *= _mur_m; \
_mur_tmp ^= _mur_tmp >> _mur_r; \
_mur_tmp *= _mur_m; \
hashv *= _mur_m; \
hashv ^= _mur_tmp; \
_mur_key += 4; \
} \
\
switch(_mur_len) \
{ \
case 3: hashv ^= _mur_key[2] << 16; \
case 2: hashv ^= _mur_key[1] << 8; \
case 1: hashv ^= _mur_key[0]; \
hashv *= _mur_m; \
}; \
\
hashv ^= hashv >> 13; \
hashv *= _mur_m; \
hashv ^= hashv >> 15; \
\
bkt = hashv & (num_bkts-1); \
} while(0)
/* Appleby's MurmurHash version for alignment-sensitive archs like Sparc */
#define HASH_MUR_ALIGNED(key,keylen,num_bkts,hashv,bkt) \
do { \
const unsigned int _mur_m = 0x5bd1e995; \
const int _mur_r = 24; \
hashv = 0xcafebabe ^ (keylen); \
char *_mur_key = (char *)(key); \
unsigned int _mur_len = keylen; \
int _mur_align = (int)_mur_key & 3; \
\
if (_mur_align && (_mur_len >= 4)) { \
unsigned _mur_t = 0, _mur_d = 0; \
switch(_mur_align) { \
case 1: _mur_t |= _mur_key[2] << 16; \
case 2: _mur_t |= _mur_key[1] << 8; \
case 3: _mur_t |= _mur_key[0]; \
} \
_mur_t <<= (8 * _mur_align); \
_mur_key += 4-_mur_align; \
_mur_len -= 4-_mur_align; \
int _mur_sl = 8 * (4-_mur_align); \
int _mur_sr = 8 * _mur_align; \
\
for (;_mur_len >= 4; _mur_len-=4) { \
_mur_d = *(unsigned *)_mur_key; \
_mur_t = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \
unsigned _mur_k = _mur_t; \
_mur_k *= _mur_m; \
_mur_k ^= _mur_k >> _mur_r; \
_mur_k *= _mur_m; \
hashv *= _mur_m; \
hashv ^= _mur_k; \
_mur_t = _mur_d; \
_mur_key += 4; \
} \
_mur_d = 0; \
if(_mur_len >= _mur_align) { \
switch(_mur_align) { \
case 3: _mur_d |= _mur_key[2] << 16; \
case 2: _mur_d |= _mur_key[1] << 8; \
case 1: _mur_d |= _mur_key[0]; \
} \
unsigned _mur_k = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \
_mur_k *= _mur_m; \
_mur_k ^= _mur_k >> _mur_r; \
_mur_k *= _mur_m; \
hashv *= _mur_m; \
hashv ^= _mur_k; \
_mur_k += _mur_align; \
_mur_len -= _mur_align; \
\
switch(_mur_len) \
{ \
case 3: hashv ^= _mur_key[2] << 16; \
case 2: hashv ^= _mur_key[1] << 8; \
case 1: hashv ^= _mur_key[0]; \
hashv *= _mur_m; \
} \
} else { \
switch(_mur_len) \
{ \
case 3: _mur_d ^= _mur_key[2] << 16; \
case 2: _mur_d ^= _mur_key[1] << 8; \
case 1: _mur_d ^= _mur_key[0]; \
case 0: hashv ^= (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \
hashv *= _mur_m; \
} \
} \
\
hashv ^= hashv >> 13; \
hashv *= _mur_m; \
hashv ^= hashv >> 15; \
} else { \
for (;_mur_len >= 4; _mur_len-=4) { \
unsigned _mur_k = *(unsigned*)_mur_key; \
_mur_k *= _mur_m; \
_mur_k ^= _mur_k >> _mur_r; \
_mur_k *= _mur_m; \
hashv *= _mur_m; \
hashv ^= _mur_k; \
_mur_key += 4; \
} \
switch(_mur_len) \
{ \
case 3: hashv ^= _mur_key[2] << 16; \
case 2: hashv ^= _mur_key[1] << 8; \
case 1: hashv ^= _mur_key[0]; \
hashv *= _mur_m; \
} \
\
hashv ^= hashv >> 13; \
hashv *= _mur_m; \
hashv ^= hashv >> 15; \
} \
bkt = hashv & (num_bkts-1); \
} while(0)
#endif /* HASH_USING_NO_STRICT_ALIASING */
/* key comparison function; return 0 if keys equal */
#define HASH_KEYCMP(a,b,len) memcmp(a,b,len)
/* iterate over items in a known bucket to find desired item */
#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \
do { \
if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
else out=NULL; \
while (out) { \
if (out->hh.keylen == keylen_in) { \
if ((HASH_KEYCMP(out->hh.key,keyptr,keylen_in)) == 0) break; \
} \
if (out->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,out->hh.hh_next)); \
else out = NULL; \
} \
} while(0)
/* add an item to a bucket */
#define HASH_ADD_TO_BKT(head,addhh) \
do { \
head.count++; \
(addhh)->hh_next = head.hh_head; \
(addhh)->hh_prev = NULL; \
if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \
(head).hh_head=addhh; \
if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \
&& (addhh)->tbl->noexpand != 1) { \
HASH_EXPAND_BUCKETS((addhh)->tbl); \
} \
} while(0)
/* remove an item from a given bucket */
#define HASH_DEL_IN_BKT(hh,head,hh_del) \
(head).count--; \
if ((head).hh_head == hh_del) { \
(head).hh_head = hh_del->hh_next; \
} \
if (hh_del->hh_prev) { \
hh_del->hh_prev->hh_next = hh_del->hh_next; \
} \
if (hh_del->hh_next) { \
hh_del->hh_next->hh_prev = hh_del->hh_prev; \
}
/* Bucket expansion has the effect of doubling the number of buckets
* and redistributing the items into the new buckets. Ideally the
* items will distribute more or less evenly into the new buckets
* (the extent to which this is true is a measure of the quality of
* the hash function as it applies to the key domain).
*
* With the items distributed into more buckets, the chain length
* (item count) in each bucket is reduced. Thus by expanding buckets
* the hash keeps a bound on the chain length. This bounded chain
* length is the essence of how a hash provides constant time lookup.
*
* The calculation of tbl->ideal_chain_maxlen below deserves some
* explanation. First, keep in mind that we're calculating the ideal
* maximum chain length based on the *new* (doubled) bucket count.
* In fractions this is just n/b (n=number of items,b=new num buckets).
* Since the ideal chain length is an integer, we want to calculate
* ceil(n/b). We don't depend on floating point arithmetic in this
* hash, so to calculate ceil(n/b) with integers we could write
*
* ceil(n/b) = (n/b) + ((n%b)?1:0)
*
* and in fact a previous version of this hash did just that.
* But now we have improved things a bit by recognizing that b is
* always a power of two. We keep its base 2 log handy (call it lb),
* so now we can write this with a bit shift and logical AND:
*
* ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
*
*/
#define HASH_EXPAND_BUCKETS(tbl) \
do { \
unsigned _he_bkt; \
unsigned _he_bkt_i; \
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
_he_new_buckets = (UT_hash_bucket*)uthash_malloc( \
2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \
memset(_he_new_buckets, 0, \
2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
tbl->ideal_chain_maxlen = \
(tbl->num_items >> (tbl->log2_num_buckets+1)) + \
((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \
tbl->nonideal_items = 0; \
for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \
{ \
_he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \
while (_he_thh) { \
_he_hh_nxt = _he_thh->hh_next; \
HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
_he_newbkt = &(_he_new_buckets[ _he_bkt ]); \
if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
tbl->nonideal_items++; \
_he_newbkt->expand_mult = _he_newbkt->count / \
tbl->ideal_chain_maxlen; \
} \
_he_thh->hh_prev = NULL; \
_he_thh->hh_next = _he_newbkt->hh_head; \
if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \
_he_thh; \
_he_newbkt->hh_head = _he_thh; \
_he_thh = _he_hh_nxt; \
} \
} \
uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
tbl->num_buckets *= 2; \
tbl->log2_num_buckets++; \
tbl->buckets = _he_new_buckets; \
tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \
(tbl->ineff_expands+1) : 0; \
if (tbl->ineff_expands > 1) { \
tbl->noexpand=1; \
uthash_noexpand_fyi(tbl); \
} \
uthash_expand_fyi(tbl); \
} while(0)
/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */
/* Note that HASH_SORT assumes the hash handle name to be hh.
* HASH_SRT was added to allow the hash handle name to be passed in. */
#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
#define HASH_SRT(hh,head,cmpfcn) \
do { \
unsigned _hs_i; \
unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \
struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \
if (head) { \
_hs_insize = 1; \
_hs_looping = 1; \
_hs_list = &((head)->hh); \
while (_hs_looping) { \
_hs_p = _hs_list; \
_hs_list = NULL; \
_hs_tail = NULL; \
_hs_nmerges = 0; \
while (_hs_p) { \
_hs_nmerges++; \
_hs_q = _hs_p; \
_hs_psize = 0; \
for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \
_hs_psize++; \
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
((void*)((char*)(_hs_q->next) + \
(head)->hh.tbl->hho)) : NULL); \
if (! (_hs_q) ) break; \
} \
_hs_qsize = _hs_insize; \
while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \
if (_hs_psize == 0) { \
_hs_e = _hs_q; \
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
((void*)((char*)(_hs_q->next) + \
(head)->hh.tbl->hho)) : NULL); \
_hs_qsize--; \
} else if ( (_hs_qsize == 0) || !(_hs_q) ) { \
_hs_e = _hs_p; \
_hs_p = (UT_hash_handle*)((_hs_p->next) ? \
((void*)((char*)(_hs_p->next) + \
(head)->hh.tbl->hho)) : NULL); \
_hs_psize--; \
} else if (( \
cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
) <= 0) { \
_hs_e = _hs_p; \
_hs_p = (UT_hash_handle*)((_hs_p->next) ? \
((void*)((char*)(_hs_p->next) + \
(head)->hh.tbl->hho)) : NULL); \
_hs_psize--; \
} else { \
_hs_e = _hs_q; \
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
((void*)((char*)(_hs_q->next) + \
(head)->hh.tbl->hho)) : NULL); \
_hs_qsize--; \
} \
if ( _hs_tail ) { \
_hs_tail->next = ((_hs_e) ? \
ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
} else { \
_hs_list = _hs_e; \
} \
_hs_e->prev = ((_hs_tail) ? \
ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
_hs_tail = _hs_e; \
} \
_hs_p = _hs_q; \
} \
_hs_tail->next = NULL; \
if ( _hs_nmerges <= 1 ) { \
_hs_looping=0; \
(head)->hh.tbl->tail = _hs_tail; \
DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
} \
_hs_insize *= 2; \
} \
HASH_FSCK(hh,head); \
} \
} while (0)
/* This function selects items from one hash into another hash.
* The end result is that the selected items have dual presence
* in both hashes. There is no copy of the items made; rather
* they are added into the new hash through a secondary hash
* hash handle that must be present in the structure. */
#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \
do { \
unsigned _src_bkt, _dst_bkt; \
void *_last_elt=NULL, *_elt; \
UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \
ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \
if (src) { \
for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
_src_hh; \
_src_hh = _src_hh->hh_next) { \
_elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
if (cond(_elt)) { \
_dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \
_dst_hh->key = _src_hh->key; \
_dst_hh->keylen = _src_hh->keylen; \
_dst_hh->hashv = _src_hh->hashv; \
_dst_hh->prev = _last_elt; \
_dst_hh->next = NULL; \
if (_last_elt_hh) { _last_elt_hh->next = _elt; } \
if (!dst) { \
DECLTYPE_ASSIGN(dst,_elt); \
HASH_MAKE_TABLE(hh_dst,dst); \
} else { \
_dst_hh->tbl = (dst)->hh_dst.tbl; \
} \
HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \
HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \
(dst)->hh_dst.tbl->num_items++; \
_last_elt = _elt; \
_last_elt_hh = _dst_hh; \
} \
} \
} \
} \
HASH_FSCK(hh_dst,dst); \
} while (0)
#define HASH_CLEAR(hh,head) \
do { \
if (head) { \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head)=NULL; \
} \
} while(0)
#ifdef NO_DECLTYPE
#define HASH_ITER(hh,head,el,tmp) \
for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL))
#else
#define HASH_ITER(hh,head,el,tmp) \
for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL))
#endif
/* obtain a count of items in the hash */
#define HASH_COUNT(head) HASH_CNT(hh,head)
#define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0)
typedef struct UT_hash_bucket {
struct UT_hash_handle *hh_head;
unsigned count;
/* expand_mult is normally set to 0. In this situation, the max chain length
* threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If
* the bucket's chain exceeds this length, bucket expansion is triggered).
* However, setting expand_mult to a non-zero value delays bucket expansion
* (that would be triggered by additions to this particular bucket)
* until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.
* (The multiplier is simply expand_mult+1). The whole idea of this
* multiplier is to reduce bucket expansions, since they are expensive, in
* situations where we know that a particular bucket tends to be overused.
* It is better to let its chain length grow to a longer yet-still-bounded
* value, than to do an O(n) bucket expansion too often.
*/
unsigned expand_mult;
} UT_hash_bucket;
/* random signature used only to find hash tables in external analysis */
#define HASH_SIGNATURE 0xa0111fe1
#define HASH_BLOOM_SIGNATURE 0xb12220f2
typedef struct UT_hash_table {
UT_hash_bucket *buckets;
unsigned num_buckets, log2_num_buckets;
unsigned num_items;
struct UT_hash_handle *tail; /* tail hh in app order, for fast append */
ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */
/* in an ideal situation (all buckets used equally), no bucket would have
* more than ceil(#items/#buckets) items. that's the ideal chain length. */
unsigned ideal_chain_maxlen;
/* nonideal_items is the number of items in the hash whose chain position
* exceeds the ideal chain maxlen. these items pay the penalty for an uneven
* hash distribution; reaching them in a chain traversal takes >ideal steps */
unsigned nonideal_items;
/* ineffective expands occur when a bucket doubling was performed, but
* afterward, more than half the items in the hash had nonideal chain
* positions. If this happens on two consecutive expansions we inhibit any
* further expansion, as it's not helping; this happens when the hash
* function isn't a good fit for the key domain. When expansion is inhibited
* the hash will still work, albeit no longer in constant time. */
unsigned ineff_expands, noexpand;
unsigned int signature; /* used only to find hash tables in external analysis */
#ifdef HASH_BLOOM
unsigned int bloom_sig; /* used only to test bloom exists in external analysis */
uint8_t *bloom_bv;
char bloom_nbits;
#endif
} UT_hash_table;
typedef struct UT_hash_handle {
struct UT_hash_table *tbl;
void *prev; /* prev element in app order */
void *next; /* next element in app order */
struct UT_hash_handle *hh_prev; /* previous hh in bucket order */
struct UT_hash_handle *hh_next; /* next hh in bucket order */
void *key; /* ptr to enclosing struct's key */
unsigned keylen; /* enclosing struct's key len */
unsigned hashv; /* result of hash-fcn(key) */
} UT_hash_handle;
#endif /* __SUPPORT_DATA_SUPPORT_UTHASH_H__*/

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<Group
location = "container:"
name = "plugins">
<FileRef
location = "group:protocols/proj.ios/PluginProtocol.xcodeproj">
</FileRef>
<FileRef
location = "group:plugins/admob/proj.ios/PluginAdmob.xcodeproj">
</FileRef>
<FileRef
location = "group:plugins/flurry/proj.ios/PluginFlurry.xcodeproj">
</FileRef>
<FileRef
location = "group:plugins/twitter/proj.ios/PluginTwitter.xcodeproj">
</FileRef>
<FileRef
location = "group:plugins/umeng/proj.ios/PluginUmeng.xcodeproj">
</FileRef>
<FileRef
location = "group:plugins/weibo/proj.ios/PluginWeibo.xcodeproj">
</FileRef>
</Group>
<FileRef
location = "group:samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="sdk/GoogleAdMobAdsSdk.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginAdmob</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,9 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.libAdsAdmob"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifestConfig xmlns:android="http://schemas.android.com/apk/res/android">
<applicationCfg keyword="com.google.ads.AdActivity">
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</applicationCfg>
<permissionCfg>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</permissionCfg>
</manifestConfig>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="libPluginAdmob" default="plugin-publish">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />
</project>

View File

@ -1,16 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-7
android.library=true
android.library.reference.1=../../../protocols/proj.android

View File

@ -1 +0,0 @@
3cf479a2b1f3e12b9d61e98d742baeb247401093

View File

@ -1,293 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
import com.google.ads.*;
import com.google.ads.AdRequest.ErrorCode;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.WindowManager;
public class AdsAdmob implements InterfaceAds {
private static final String LOG_TAG = "AdsAdmob";
private static Activity mContext = null;
private static boolean bDebug = false;
private static AdsAdmob mAdapter = null;
private AdView adView = null;
private String mPublishID = "";
private Set<String> mTestDevices = null;
private WindowManager mWm = null;
private static final int ADMOB_SIZE_BANNER = 1;
private static final int ADMOB_SIZE_IABMRect = 2;
private static final int ADMOB_SIZE_IABBanner = 3;
private static final int ADMOB_SIZE_IABLeaderboard = 4;
private static final int ADMOB_SIZE_Skyscraper = 5;
private static final int ADMOB_TYPE_BANNER = 1;
private static final int ADMOB_TYPE_FULLSCREEN = 2;
protected static void LogE(String msg, Exception e) {
Log.e(LOG_TAG, msg, e);
e.printStackTrace();
}
protected static void LogD(String msg) {
if (bDebug) {
Log.d(LOG_TAG, msg);
}
}
public AdsAdmob(Context context) {
mContext = (Activity) context;
mAdapter = this;
}
@Override
public void setDebugMode(boolean debug) {
bDebug = debug;
}
@Override
public String getSDKVersion() {
return "6.3.1";
}
@Override
public void configDeveloperInfo(Hashtable<String, String> devInfo) {
try {
mPublishID = devInfo.get("AdmobID");
LogD("init AppInfo : " + mPublishID);
} catch (Exception e) {
LogE("initAppInfo, The format of appInfo is wrong", e);
}
}
@Override
public void showAds(Hashtable<String, String> info, int pos) {
try
{
String strType = info.get("AdmobType");
int adsType = Integer.parseInt(strType);
switch (adsType) {
case ADMOB_TYPE_BANNER:
{
String strSize = info.get("AdmobSizeEnum");
int sizeEnum = Integer.parseInt(strSize);
showBannerAd(sizeEnum, pos);
break;
}
case ADMOB_TYPE_FULLSCREEN:
LogD("Now not support full screen view in Admob");
break;
default:
break;
}
} catch (Exception e) {
LogE("Error when show Ads ( " + info.toString() + " )", e);
}
}
@Override
public void spendPoints(int points) {
LogD("Admob not support spend points!");
}
@Override
public void hideAds(Hashtable<String, String> info) {
try
{
String strType = info.get("AdmobType");
int adsType = Integer.parseInt(strType);
switch (adsType) {
case ADMOB_TYPE_BANNER:
hideBannerAd();
break;
case ADMOB_TYPE_FULLSCREEN:
LogD("Now not support full screen view in Admob");
break;
default:
break;
}
} catch (Exception e) {
LogE("Error when hide Ads ( " + info.toString() + " )", e);
}
}
private void showBannerAd(int sizeEnum, int pos) {
final int curPos = pos;
final int curSize = sizeEnum;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
// destory the ad view before
if (null != adView) {
if (null != mWm) {
mWm.removeView(adView);
}
adView.destroy();
adView = null;
}
AdSize size = AdSize.BANNER;
switch (curSize) {
case AdsAdmob.ADMOB_SIZE_BANNER:
size = AdSize.BANNER;
break;
case AdsAdmob.ADMOB_SIZE_IABMRect:
size = AdSize.IAB_MRECT;
break;
case AdsAdmob.ADMOB_SIZE_IABBanner:
size = AdSize.IAB_BANNER;
break;
case AdsAdmob.ADMOB_SIZE_IABLeaderboard:
size = AdSize.IAB_LEADERBOARD;
break;
case AdsAdmob.ADMOB_SIZE_Skyscraper:
size = AdSize.IAB_WIDE_SKYSCRAPER;
break;
default:
break;
}
adView = new AdView(mContext, size, mPublishID);
AdRequest req = new AdRequest();
try {
if (mTestDevices != null) {
Iterator<String> ir = mTestDevices.iterator();
while(ir.hasNext())
{
req.addTestDevice(ir.next());
}
}
} catch (Exception e) {
LogE("Error during add test device", e);
}
adView.loadAd(req);
adView.setAdListener(new AdmobAdsListener());
if (null == mWm) {
mWm = (WindowManager) mContext.getSystemService("window");
}
AdsWrapper.addAdView(mWm, adView, curPos);
}
});
}
private void hideBannerAd() {
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
if (null != adView) {
if (null != mWm) {
mWm.removeView(adView);
}
adView.destroy();
adView = null;
}
}
});
}
public void addTestDevice(String deviceID) {
LogD("addTestDevice invoked : " + deviceID);
if (null == mTestDevices) {
mTestDevices = new HashSet<String>();
}
mTestDevices.add(deviceID);
}
private class AdmobAdsListener implements AdListener {
@Override
public void onDismissScreen(Ad arg0) {
LogD("onDismissScreen invoked");
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads view dismissed!");
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
int errorNo = AdsWrapper.RESULT_CODE_UnknownError;
String errorMsg = "Unknow error";
switch (arg1) {
case NETWORK_ERROR:
errorNo = AdsWrapper.RESULT_CODE_NetworkError;
errorMsg = "Network error";
break;
case INVALID_REQUEST:
errorNo = AdsWrapper.RESULT_CODE_NetworkError;
errorMsg = "The ad request is invalid";
break;
case NO_FILL:
errorMsg = "The ad request is successful, but no ad was returned due to lack of ad inventory.";
break;
default:
break;
}
LogD("failed to receive ad : " + errorNo + " , " + errorMsg);
AdsWrapper.onAdsResult(mAdapter, errorNo, errorMsg);
}
@Override
public void onLeaveApplication(Ad arg0) {
LogD("onLeaveApplication invoked");
}
@Override
public void onPresentScreen(Ad arg0) {
LogD("onPresentScreen invoked");
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsShown, "Ads view shown!");
}
@Override
public void onReceiveAd(Ad arg0) {
LogD("onReceiveAd invoked");
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsReceived, "Ads request received success!");
}
}
@Override
public String getPluginVersion() {
return "0.2.0";
}
@Override
public void queryPoints() {
LogD("Admob not support query points!");
}
}

View File

@ -1,18 +0,0 @@
//
// GADAdMobExtras.h
// Google Ads iOS SDK
//
// Copyright (c) 2012 Google Inc. All rights reserved.
//
// The additional parameters publishers may send to the AdMob network.
//
#import <Foundation/Foundation.h>
#import "GADAdNetworkExtras.h"
@interface GADAdMobExtras : NSObject <GADAdNetworkExtras>
@property (nonatomic, retain) NSDictionary *additionalParameters;
@end

View File

@ -1,18 +0,0 @@
//
// GADAdNetworkExtras.h
// Google Ads iOS SDK
//
// Copyright (c) 2012 Google Inc. All rights reserved.
//
// An object implementing this protocol contains information set by the
// publisher on the client device for a particular ad network.
//
// Ad networks should create an 'extras' object implementing this protocol for
// their publishers to use.
//
#import <Foundation/Foundation.h>
@protocol GADAdNetworkExtras <NSObject>
@end

View File

@ -1,92 +0,0 @@
//
// GADAdSize.h
// Google Ads iOS SDK
//
// Copyright 2012 Google Inc. All rights reserved.
//
// A valid GADAdSize is considered to be one of the predefined GADAdSize
// constants or a GADAdSize constructed by GADAdSizeFromCGSize,
// GADAdSizeFullWidthPortraitWithHeight, GADAdSizeFullWidthLandscapeWithHeight.
//
#import <UIKit/UIKit.h>
// Do not create a GADAdSize manually. Use one of the kGADAdSize constants.
// Treat GADAdSize as an opaque type. Do not access any fields directly. To
// obtain a concrete CGSize, use the function CGSizeFromGADAdSize().
typedef struct GADAdSize {
CGSize size;
NSUInteger flags;
} GADAdSize;
#pragma mark Standard Sizes
// iPhone and iPod Touch ad size. Typically 320x50.
extern GADAdSize const kGADAdSizeBanner;
// Medium Rectangle size for the iPad (especially in a UISplitView's left pane).
// Typically 300x250.
extern GADAdSize const kGADAdSizeMediumRectangle;
// Full Banner size for the iPad (especially in a UIPopoverController or in
// UIModalPresentationFormSheet). Typically 468x60.
extern GADAdSize const kGADAdSizeFullBanner;
// Leaderboard size for the iPad. Typically 728x90.
extern GADAdSize const kGADAdSizeLeaderboard;
// Skyscraper size for the iPad. Mediation only. AdMob/Google does not offer
// this size. Typically 120x600.
extern GADAdSize const kGADAdSizeSkyscraper;
// An ad size that spans the full width of the application in portrait
// orientation. The height is typically 50 pixels on an iPhone/iPod UI, and 90
// pixels tall on an iPad UI.
extern GADAdSize const kGADAdSizeSmartBannerPortrait;
// An ad size that spans the full width of the application in landscape
// orientation. The height is typically 32 pixels on an iPhone/iPod UI, and 90
// pixels tall on an iPad UI.
extern GADAdSize const kGADAdSizeSmartBannerLandscape;
// Invalid ad size marker.
extern GADAdSize const kGADAdSizeInvalid;
#pragma mark Custom Sizes
// Given a CGSize, return a custom GADAdSize. Use this only if you require a
// non-standard size, otherwise, use one of the standard size constants above.
GADAdSize GADAdSizeFromCGSize(CGSize size);
// Get a custom GADAdSize that spans the full width of the application in
// portrait orientation with the height provided.
GADAdSize GADAdSizeFullWidthPortraitWithHeight(CGFloat height);
// Get a custom GADAdSize that spans the full width of the application in
// landscape orientation with the height provided.
GADAdSize GADAdSizeFullWidthLandscapeWithHeight(CGFloat height);
#pragma mark Convenience Functions
// Checks whether the two GADAdSizes are equal.
BOOL GADAdSizeEqualToSize(GADAdSize size1, GADAdSize size2);
// Given a GADAdSize constant, returns a CGSize. If the GADAdSize is unknown,
// returns CGSizeZero.
CGSize CGSizeFromGADAdSize(GADAdSize size);
// Determines if |size| is one of the predefined constants, or a custom
// GADAdSize generated by FromCGSize.
BOOL IsGADAdSizeValid(GADAdSize size);
// Given a GADAdSize constant, returns a NSString describing the GADAdSize.
NSString *NSStringFromGADAdSize(GADAdSize size);
#pragma mark Deprecated Macros
#define GAD_SIZE_320x50 CGSizeFromGADAdSize(kGADAdSizeBanner)
#define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle)
#define GAD_SIZE_468x60 CGSizeFromGADAdSize(kGADAdSizeFullBanner)
#define GAD_SIZE_728x90 CGSizeFromGADAdSize(kGADAdSizeLeaderboard)
#define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper)

View File

@ -1,114 +0,0 @@
//
// GADBannerView.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GADAdSize.h"
#import "GADRequest.h"
#import "GADRequestError.h"
#import "GADBannerViewDelegate.h"
// The view that displays banner ads. A minimum implementation to get an ad
// from within a UIViewController class is:
//
// // Create and setup the ad view, specifying the size and origin at {0, 0}.
// GADBannerView *adView =
// [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// adView.rootViewController = self;
// adView.adUnitID = @"ID created when registering my app";
//
// // Place the ad view onto the screen.
// [self.view addSubview:adView];
// [adView release];
//
// // Request an ad without any additional targeting information.
// [adView loadRequest:nil];
//
@interface GADBannerView : UIView
#pragma mark Initialization
// Initializes a GADBannerView and sets it to the specified size, and specifies
// its placement within its superview bounds. If |size| is invalid, an
// instance of GADBannerView is not created and nil is returned instead.
- (id)initWithAdSize:(GADAdSize)size origin:(CGPoint)origin;
// Initializes a GADBannerView and sets it to the specified size, and specifies
// its placement at the top left of its superview. If |size| is invalid, an
// instance of GADBannerView is not created and nil is returned instead.
- (id)initWithAdSize:(GADAdSize)size;
#pragma mark Pre-Request
// Required value created in the AdSense website. Create a new ad unit for
// every unique placement of an ad in your application. Set this to the ID
// assigned for this placement. Ad units are important for targeting and stats.
// Example values for different request types:
// AdMob: a0123456789ABCD
// DFP: /0123/ca-pub-0123456789012345/my-ad-identifier
// AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier
// Mediation: AB123456789ABCDE
@property (nonatomic, copy) NSString *adUnitID;
// Required reference to the current root view controller. For example the root
// view controller in tab-based application would be the UITabViewController.
@property (nonatomic, assign) UIViewController *rootViewController;
// Required to set this banner view to a proper size. Never create your own
// GADAdSize directly. Use one of the predefined standard ad sizes
// (such as kGADAdSizeBanner), or create one using the GADAdSizeFromCGSize
// method. If not using mediation, then changing the adSize after an ad has
// been shown will cause a new request (for an ad of the new size) to be sent.
// If using mediation, then a new request may not be sent.
@property (nonatomic) GADAdSize adSize;
// Optional delegate object that receives state change notifications from this
// GADBannerView. Typically this is a UIViewController, however, if you are
// unfamiliar with the delegate pattern it is recommended you subclass this
// GADBannerView and make it the delegate. That avoids any chance of your
// application crashing if you forget to nil out the delegate. For example:
//
// @interface MyAdView : GADBannerView <GADBannerViewDelegate>
// @end
//
// @implementation MyAdView
// - (id)initWithFrame:(CGRect)frame {
// if ((self = [super initWithFrame:frame])) {
// self.delegate = self;
// }
// return self;
// }
//
// - (void)dealloc {
// self.delegate = nil;
// [super dealloc];
// }
//
// @end
//
@property (nonatomic, assign) NSObject<GADBannerViewDelegate> *delegate;
#pragma mark Making an Ad Request
// Makes an ad request. Additional targeting options can be supplied with a
// request object. Refresh the ad by calling this method again.
- (void)loadRequest:(GADRequest *)request;
#pragma mark Ad Request
// YES, if the currently displayed ad (or most recent failure) was a result of
// auto refreshing as specified on server. This will be set to NO after each
// loadRequest: method.
@property (nonatomic, readonly) BOOL hasAutoRefreshed;
#pragma mark Mediation
// Gets the underlying ad view of the mediated ad network.
// You may use this to find out the actual size of the ad and adjust
// GADBannerView to fit the underlying ad view.
@property (nonatomic, readonly) UIView *mediatedAdView;
@end

View File

@ -1,61 +0,0 @@
//
// GADBannerViewDelegate.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GADRequestError;
@class GADBannerView;
// Delegate for receiving state change messages from a GADBannerView such as ad
// requests succeeding/failing or when an ad has been clicked.
@protocol GADBannerViewDelegate <NSObject>
@optional
#pragma mark Ad Request Lifecycle Notifications
// Sent when an ad request loaded an ad. This is a good opportunity to add this
// view to the hierarchy if it has not yet been added. If the ad was received
// as a part of the server-side auto refreshing, you can examine the
// hasAutoRefreshed property of the view.
- (void)adViewDidReceiveAd:(GADBannerView *)view;
// Sent when an ad request failed. Normally this is because no network
// connection was available or no ads were available (i.e. no fill). If the
// error was received as a part of the server-side auto refreshing, you can
// examine the hasAutoRefreshed property of the view.
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error;
#pragma mark Click-Time Lifecycle Notifications
// Sent just before presenting the user a full screen view, such as a browser,
// in response to clicking on an ad. Use this opportunity to stop animations,
// time sensitive interactions, etc.
//
// Normally the user looks at the ad, dismisses it, and control returns to your
// application by calling adViewDidDismissScreen:. However if the user hits the
// Home button or clicks on an App Store link your application will end. On iOS
// 4.0+ the next method called will be applicationWillResignActive: of your
// UIViewController (UIApplicationWillResignActiveNotification). Immediately
// after that adViewWillLeaveApplication: is called.
- (void)adViewWillPresentScreen:(GADBannerView *)adView;
// Sent just before dismissing a full screen view.
- (void)adViewWillDismissScreen:(GADBannerView *)adView;
// Sent just after dismissing a full screen view. Use this opportunity to
// restart anything you may have stopped as part of adViewWillPresentScreen:.
- (void)adViewDidDismissScreen:(GADBannerView *)adView;
// Sent just before the application will background or terminate because the
// user clicked on an ad that will launch another application (such as the App
// Store). The normal UIApplicationDelegate methods, like
// applicationDidEnterBackground:, will be called immediately before this.
- (void)adViewWillLeaveApplication:(GADBannerView *)adView;
@end

View File

@ -1,80 +0,0 @@
//
// GADInterstitial.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GADInterstitialDelegate.h"
#import "GADRequest.h"
#import "GADRequestError.h"
// An interstitial ad. This is a full-screen advertisement shown at natural
// transition points in your application such as between game levels or news
// stories.
//
// Interstitials are shown sparingly. Expect low to no fill.
@interface GADInterstitial : NSObject
#pragma mark Pre-Request
// Required value created in the AdSense website. Create a new ad unit for
// every unique placement of an ad in your application. Set this to the ID
// assigned for this placement. Ad units are important for targeting and stats.
// Example values for different request types:
// AdMob: a0123456789ABCD
// DFP: /0123/ca-pub-0123456789012345/my-ad-identifier
// AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier
@property (nonatomic, copy) NSString *adUnitID;
// Optional delegate object that receives state change notifications from this
// GADInterstitalAd. Remember to nil the delegate before deallocating this
// object.
@property (nonatomic, assign) NSObject<GADInterstitialDelegate> *delegate;
#pragma mark Making an Ad Request
// Makes an interstitial ad request. Additional targeting options can be
// supplied with a request object. Only one interstitial request is allowed at
// a time.
//
// This is best to do several seconds before the interstitial is needed to
// preload its content. Then when transitioning between view controllers show
// the interstital with presentFromViewController.
- (void)loadRequest:(GADRequest *)request;
#pragma mark Request at Application Launch
// The |window| will be shown with the |image| displayed until either the
// |request| interstitial is shown or a timeout occurs. The delegate will
// receive an interstitialDidDismissScreen: callback to indicate that your app
// should continue when the interstitial has finished.
- (void)loadAndDisplayRequest:(GADRequest *)request
usingWindow:(UIWindow *)window
initialImage:(UIImage *)image;
#pragma mark Post-Request
// Returns YES if the interstitial is ready to be displayed. The delegate's
// interstitialAdDidReceiveAd: will be called when this switches from NO to YES.
@property (nonatomic, readonly) BOOL isReady;
// Returns YES if the interstitial object has already shown an interstitial.
// Note that an interstitial object can only be used once even with different
// requests.
@property (nonatomic, readonly) BOOL hasBeenUsed;
// Presents the interstitial ad which takes over the entire screen until the
// user dismisses it. This has no effect unless isReady returns YES and/or the
// delegate's interstitialDidReceiveAd: has been received.
//
// Set rootViewController to the current view controller at the time this method
// is called. If your application does not use view controllers pass in nil and
// your views will be removed from the window to show the interstitial and
// restored when done. After the interstitial has been removed, the delegate's
// interstitialDidDismissScreen: will be called.
- (void)presentFromRootViewController:(UIViewController *)rootViewController;
@end

View File

@ -1,53 +0,0 @@
//
// GADInterstitialDelegate.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GADInterstitial;
@class GADRequestError;
// Delegate for receiving state change messages from a GADInterstitial such as
// interstitial ad requests succeeding/failing.
@protocol GADInterstitialDelegate <NSObject>
@optional
#pragma mark Ad Request Lifecycle Notifications
// Sent when an interstitial ad request succeeded. Show it at the next
// transition point in your application such as when transitioning between view
// controllers.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad;
// Sent when an interstitial ad request completed without an interstitial to
// show. This is common since interstitials are shown sparingly to users.
- (void)interstitial:(GADInterstitial *)ad
didFailToReceiveAdWithError:(GADRequestError *)error;
#pragma mark Display-Time Lifecycle Notifications
// Sent just before presenting an interstitial. After this method finishes the
// interstitial will animate onto the screen. Use this opportunity to stop
// animations and save the state of your application in case the user leaves
// while the interstitial is on screen (e.g. to visit the App Store from a link
// on the interstitial).
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad;
// Sent before the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad;
// Sent just after dismissing an interstitial and it has animated off the
// screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad;
// Sent just before the application will background or terminate because the
// user clicked on an ad that will launch another application (such as the App
// Store). The normal UIApplicationDelegate methods, like
// applicationDidEnterBackground:, will be called immediately before this.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad;
@end

View File

@ -1,105 +0,0 @@
//
// GADRequest.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
@protocol GADAdNetworkExtras;
// Constant for getting test ads on the simulator using the testDevices method.
#define GAD_SIMULATOR_ID @"Simulator"
// Genders to help deliver more relevant ads.
typedef enum {
kGADGenderUnknown,
kGADGenderMale,
kGADGenderFemale
} GADGender;
// Specifies optional parameters for ad requests.
@interface GADRequest : NSObject <NSCopying>
// Creates an autoreleased GADRequest.
+ (GADRequest *)request;
#pragma mark Additional Parameters For Ad Networks
// Ad networks may have additional parameters they accept. To pass these
// parameters to them, create the ad network extras object for that network,
// fill in the parameters, and register it here. The ad network should have a
// header defining the interface for the 'extras' object to create. All
// networks will have access to the basic settings you've set in this GADRequest
// (gender, birthday, testing mode, etc.). If you register an extras object
// that is the same class as one you have registered before, the previous
// extras will be overwritten.
- (void)registerAdNetworkExtras:(id<GADAdNetworkExtras>)extras;
// Get the network extras defined for an ad network.
- (id<GADAdNetworkExtras>)adNetworkExtrasFor:(Class<GADAdNetworkExtras>)clazz;
// Unsets the extras for an ad network. |clazz| is the class which represents
// that network's extras type.
- (void)removeAdNetworkExtrasFor:(Class<GADAdNetworkExtras>)clazz;
// Extras sent to the mediation server (if using Mediation). For future use.
@property (nonatomic, retain) NSDictionary *mediationExtras;
#pragma mark Collecting SDK Information
// Returns the version of the SDK.
+ (NSString *)sdkVersion;
#pragma mark Testing
// Add the device's identifier into this array for testing purposes.
@property (nonatomic, retain) NSArray *testDevices;
#pragma mark User Information
// The user's gender may be used to deliver more relevant ads.
@property (nonatomic, assign) GADGender gender;
// The user's birthday may be used to deliver more relevant ads.
@property (nonatomic, retain) NSDate *birthday;
- (void)setBirthdayWithMonth:(NSInteger)m day:(NSInteger)d year:(NSInteger)y;
// The user's current location may be used to deliver more relevant ads.
// However do not use Core Location just for advertising, make sure it is used
// for more beneficial reasons as well. It is both a good idea and part of
// Apple's guidelines.
- (void)setLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude
accuracy:(CGFloat)accuracyInMeters;
// When Core Location isn't available but the user's location is known supplying
// it here may deliver more relevant ads. It can be any free-form text such as
// @"Champs-Elysees Paris" or @"94041 US".
- (void)setLocationWithDescription:(NSString *)locationDescription;
#pragma mark Contextual Information
// A keyword is a word or phrase describing the current activity of the user
// such as @"Sports Scores". Each keyword is an NSString in the NSArray. To
// clear the keywords set this to nil.
@property (nonatomic, retain) NSMutableArray *keywords;
// Convenience method for adding keywords one at a time such as @"Sports Scores"
// and then @"Football".
- (void)addKeyword:(NSString *)keyword;
#pragma mark -
#pragma mark Deprecated Methods
// Accesses the additionalParameters for the "GoogleAdmob" ad network. Please
// use -registerAdNetworkExtras: method above and pass an instance of
// GADAdMobExtras instead.
@property (nonatomic, retain) NSDictionary *additionalParameters;
// This property has been deprecated with the latest SDK releases. Please use
// testDevices.
@property (nonatomic, getter=isTesting) BOOL testing;
@end

View File

@ -1,58 +0,0 @@
//
// GADRequestError.h
// Google AdMob Ads SDK
//
// Copyright 2011 Google Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GADRequest;
extern NSString *kGADErrorDomain;
// NSError codes for GAD error domain.
typedef enum {
// The ad request is invalid. The localizedFailureReason error description
// will have more details. Typically this is because the ad did not have the
// ad unit ID or root view controller set.
kGADErrorInvalidRequest,
// The ad request was successful, but no ad was returned.
kGADErrorNoFill,
// There was an error loading data from the network.
kGADErrorNetworkError,
// The ad server experienced a failure processing the request.
kGADErrorServerError,
// The current device's OS is below the minimum required version.
kGADErrorOSVersionTooLow,
// The request was unable to be loaded before being timed out.
kGADErrorTimeout,
// Will not send request because the interstitial object has already been
// used.
kGADErrorInterstitialAlreadyUsed,
// The mediation response was invalid.
kGADErrorMediationDataError,
// Error finding or creating a mediation ad network adapter.
kGADErrorMediationAdapterError,
// The mediation request was successful, but no ad was returned from any
// ad networks.
kGADErrorMediationNoFill,
// Attempting to pass an invalid ad size to an adapter.
kGADErrorMediationInvalidAdSize,
} GADErrorCode;
// This class represents the error generated due to invalid request parameters.
@interface GADRequestError : NSError
@end

View File

@ -1 +0,0 @@
75b3945d48c14d4e433109c6c13a1e4bece6be68

View File

@ -1,69 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <Foundation/Foundation.h>
#import "InterfaceAds.h"
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"
typedef enum {
kSizeBanner = 1,
kSizeIABMRect,
kSizeIABBanner,
kSizeIABLeaderboard,
kSizeSkyscraper,
} AdmobSizeEnum;
typedef enum {
kTypeBanner = 1,
kTypeFullScreen,
} AdmobType;
@interface AdsAdmob : NSObject <InterfaceAds, GADBannerViewDelegate>
{
}
@property BOOL debug;
@property (copy, nonatomic) NSString* strPublishID;
@property (assign, nonatomic) GADBannerView* bannerView;
@property (assign, nonatomic) NSMutableArray* testDeviceIDs;
/**
interfaces from InterfaceAds
*/
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
- (void) showAds: (NSMutableDictionary*) info position:(int) pos;
- (void) hideAds: (NSMutableDictionary*) info;
- (void) queryPoints;
- (void) spendPoints: (int) points;
- (void) setDebugMode: (BOOL) isDebugMode;
- (NSString*) getSDKVersion;
- (NSString*) getPluginVersion;
/**
interface for Admob SDK
*/
- (void) addTestDevice: (NSString*) deviceID;
@end

View File

@ -1,203 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "AdsAdmob.h"
#import "AdsWrapper.h"
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
@implementation AdsAdmob
@synthesize debug = __debug;
@synthesize strPublishID = __PublishID;
@synthesize testDeviceIDs = __TestDeviceIDs;
- (void) dealloc
{
if (self.bannerView != nil) {
[self.bannerView release];
self.bannerView = nil;
}
if (self.testDeviceIDs != nil) {
[self.testDeviceIDs release];
self.testDeviceIDs = nil;
}
[super dealloc];
}
#pragma mark InterfaceAds impl
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo
{
self.strPublishID = (NSString*) [devInfo objectForKey:@"AdmobID"];
}
- (void) showAds: (NSMutableDictionary*) info position:(int) pos
{
if (self.strPublishID == nil ||
[self.strPublishID length] == 0) {
OUTPUT_LOG(@"configDeveloperInfo() not correctly invoked in Admob!");
return;
}
NSString* strType = [info objectForKey:@"AdmobType"];
int type = [strType intValue];
switch (type) {
case kTypeBanner:
{
NSString* strSize = [info objectForKey:@"AdmobSizeEnum"];
int sizeEnum = [strSize intValue];
[self showBanner:sizeEnum atPos:pos];
break;
}
case kTypeFullScreen:
OUTPUT_LOG(@"Now not support full screen view in Admob");
break;
default:
OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)");
break;
}
}
- (void) hideAds: (NSMutableDictionary*) info
{
NSString* strType = [info objectForKey:@"AdmobType"];
int type = [strType intValue];
switch (type) {
case kTypeBanner:
{
if (nil != self.bannerView) {
[self.bannerView removeFromSuperview];
[self.bannerView release];
self.bannerView = nil;
}
break;
}
case kTypeFullScreen:
OUTPUT_LOG(@"Now not support full screen view in Admob");
break;
default:
OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)");
break;
}
}
- (void) queryPoints
{
OUTPUT_LOG(@"Admob not support query points!");
}
- (void) spendPoints: (int) points
{
OUTPUT_LOG(@"Admob not support spend points!");
}
- (void) setDebugMode: (BOOL) isDebugMode
{
self.debug = isDebugMode;
}
- (NSString*) getSDKVersion
{
return @"6.4.2";
}
- (NSString*) getPluginVersion
{
return @"0.2.0";
}
- (void) showBanner: (int) sizeEnum atPos:(int) pos
{
GADAdSize size = kGADAdSizeBanner;
switch (sizeEnum) {
case kSizeBanner:
size = kGADAdSizeBanner;
break;
case kSizeIABMRect:
size = kGADAdSizeMediumRectangle;
break;
case kSizeIABBanner:
size = kGADAdSizeFullBanner;
break;
case kSizeIABLeaderboard:
size = kGADAdSizeLeaderboard;
break;
case kSizeSkyscraper:
size = kGADAdSizeSkyscraper;
break;
default:
break;
}
if (nil != self.bannerView) {
[self.bannerView removeFromSuperview];
[self.bannerView release];
self.bannerView = nil;
}
self.bannerView = [[GADBannerView alloc] initWithAdSize:size];
self.bannerView.adUnitID = self.strPublishID;
self.bannerView.delegate = self;
[self.bannerView setRootViewController:[AdsWrapper getCurrentRootViewController]];
[AdsWrapper addAdView:self.bannerView atPos:pos];
GADRequest* request = [GADRequest request];
request.testDevices = [NSArray arrayWithArray:self.testDeviceIDs];
[self.bannerView loadRequest:request];
}
#pragma mark interface for Admob SDK
- (void) addTestDevice: (NSString*) deviceID
{
if (nil == self.testDeviceIDs) {
self.testDeviceIDs = [NSMutableArray alloc];
[self.testDeviceIDs addObject:GAD_SIMULATOR_ID];
}
[self.testDeviceIDs addObject:deviceID];
}
#pragma mark GADBannerViewDelegate impl
// Since we've received an ad, let's go ahead and set the frame to display it.
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(@"Received ad");
[AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"Ads request received success!"];
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
int errorNo = kUnknownError;
switch ([error code]) {
case kGADErrorNetworkError:
errorNo = kNetworkError;
break;
default:
break;
}
[AdsWrapper onAdsResult:self withRet:errorNo withMsg:[error localizedDescription]];
}
@end

View File

@ -1,7 +0,0 @@
//
// Prefix header for all source files of the 'PluginAdmob' target in the 'PluginAdmob' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif

View File

@ -1,276 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44AA176EA82000B2D5ED /* Foundation.framework */; };
FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */; };
FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C4176EA84500B2D5ED /* AdsAdmob.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
FADC44A5176EA82000B2D5ED /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/${PRODUCT_NAME}";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginAdmob.a; sourceTree = BUILT_PRODUCTS_DIR; };
FADC44AA176EA82000B2D5ED /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdMobExtras.h; sourceTree = "<group>"; };
FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdNetworkExtras.h; sourceTree = "<group>"; };
FADC44BB176EA84500B2D5ED /* GADAdSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdSize.h; sourceTree = "<group>"; };
FADC44BC176EA84500B2D5ED /* GADBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerView.h; sourceTree = "<group>"; };
FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerViewDelegate.h; sourceTree = "<group>"; };
FADC44BE176EA84500B2D5ED /* GADInterstitial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitial.h; sourceTree = "<group>"; };
FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitialDelegate.h; sourceTree = "<group>"; };
FADC44C0176EA84500B2D5ED /* GADRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequest.h; sourceTree = "<group>"; };
FADC44C1176EA84500B2D5ED /* GADRequestError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequestError.h; sourceTree = "<group>"; };
FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGoogleAdMobAds.a; sourceTree = "<group>"; };
FADC44C3176EA84500B2D5ED /* AdsAdmob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsAdmob.h; sourceTree = "<group>"; };
FADC44C4176EA84500B2D5ED /* AdsAdmob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdsAdmob.m; sourceTree = "<group>"; };
FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginAdmob-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FADC44A4176EA82000B2D5ED /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */,
FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FADC449E176EA82000B2D5ED = {
isa = PBXGroup;
children = (
FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */,
FADC44B8176EA84500B2D5ED /* Admob */,
FADC44C3176EA84500B2D5ED /* AdsAdmob.h */,
FADC44C4176EA84500B2D5ED /* AdsAdmob.m */,
FADC44A9176EA82000B2D5ED /* Frameworks */,
FADC44A8176EA82000B2D5ED /* Products */,
);
sourceTree = "<group>";
};
FADC44A8176EA82000B2D5ED /* Products */ = {
isa = PBXGroup;
children = (
FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */,
);
name = Products;
sourceTree = "<group>";
};
FADC44A9176EA82000B2D5ED /* Frameworks */ = {
isa = PBXGroup;
children = (
FADC44AA176EA82000B2D5ED /* Foundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
FADC44B8176EA84500B2D5ED /* Admob */ = {
isa = PBXGroup;
children = (
FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */,
FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */,
FADC44BB176EA84500B2D5ED /* GADAdSize.h */,
FADC44BC176EA84500B2D5ED /* GADBannerView.h */,
FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */,
FADC44BE176EA84500B2D5ED /* GADInterstitial.h */,
FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */,
FADC44C0176EA84500B2D5ED /* GADRequest.h */,
FADC44C1176EA84500B2D5ED /* GADRequestError.h */,
FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */,
);
path = Admob;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FADC44A6176EA82000B2D5ED /* PluginAdmob */ = {
isa = PBXNativeTarget;
buildConfigurationList = FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */;
buildPhases = (
FADC44A3176EA82000B2D5ED /* Sources */,
FADC44A4176EA82000B2D5ED /* Frameworks */,
FADC44A5176EA82000B2D5ED /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = PluginAdmob;
productName = PluginAdmob;
productReference = FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FADC449F176EA82000B2D5ED /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "cocos2d-x";
};
buildConfigurationList = FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = FADC449E176EA82000B2D5ED;
productRefGroup = FADC44A8176EA82000B2D5ED /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FADC44A6176EA82000B2D5ED /* PluginAdmob */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
FADC44A3176EA82000B2D5ED /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
FADC44B3176EA82000B2D5ED /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
FADC44B4176EA82000B2D5ED /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FADC44B6176EA82000B2D5ED /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginAdmob.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Admob\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
FADC44B7176EA82000B2D5ED /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginAdmob.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/Admob\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FADC44B3176EA82000B2D5ED /* Debug */,
FADC44B4176EA82000B2D5ED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FADC44B6176EA82000B2D5ED /* Debug */,
FADC44B7176EA82000B2D5ED /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FADC449F176EA82000B2D5ED /* Project object */;
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="sdk/alipay_plugin.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginAlipay</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,9 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.libIAPAlipay"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

View File

@ -1 +0,0 @@
db46ceaf2554c8d9e48cdaec3a4cdf5519bb8896

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifestConfig xmlns:android="http://schemas.android.com/apk/res/android">
<permissionCfg>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</permissionCfg>
</manifestConfig>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="libPluginAlipay" default="plugin-publish">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />
</project>

View File

@ -1,16 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-7
android.library=true
android.library.reference.1=../../../protocols/proj.android

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
public final class AlixId
{
public static final int BASE_ID = 0;
public static final int RQF_PAY = BASE_ID + 1;
public static final int RQF_INSTALL_CHECK = RQF_PAY + 1;
}
final class AlixDefine
{
public static final String IMEI = "imei";
public static final String IMSI = "imsi";
public static final String KEY = "key";
public static final String USER_AGENT = "user_agent";
public static final String VERSION = "version";
public static final String DEVICE = "device";
public static final String SID = "sid";
public static final String partner = "partner";
public static final String charset = "charset";
public static final String sign_type = "sign_type";
public static final String sign = "sign";
public static final String URL = "URL";
public static final String split = "&";
public static final String AlixPay = "AlixPay";
public static final String action = "action";
public static final String actionUpdate= "update";
public static final String data = "data";
public static final String platform = "platform";
}

View File

@ -1,295 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
/**
* Base64 工具类
*
*/
public final class Base64 {
static private final int BASELENGTH = 128;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final char PAD = '=';
static private final boolean fDebug = false;
static final private byte[] base64Alphabet = new byte[BASELENGTH];
static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
static {
for (int i = 0; i < BASELENGTH; ++i) {
base64Alphabet[i] = -1;
}
for (int i = 'Z'; i >= 'A'; i--) {
base64Alphabet[i] = (byte) (i - 'A');
}
for (int i = 'z'; i >= 'a'; i--) {
base64Alphabet[i] = (byte) (i - 'a' + 26);
}
for (int i = '9'; i >= '0'; i--) {
base64Alphabet[i] = (byte) (i - '0' + 52);
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i <= 25; i++) {
lookUpBase64Alphabet[i] = (char) ('A' + i);
}
for (int i = 26, j = 0; i <= 51; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('a' + j);
}
for (int i = 52, j = 0; i <= 61; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('0' + j);
}
lookUpBase64Alphabet[62] = (char) '+';
lookUpBase64Alphabet[63] = (char) '/';
}
private static boolean isWhiteSpace(char octect) {
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
}
private static boolean isPad(char octect) {
return (octect == PAD);
}
private static boolean isData(char octect) {
return (octect < BASELENGTH && base64Alphabet[octect] != -1);
}
/**
* Encodes hex octects into Base64
*
* @param binaryData
* Array containing binaryData
* @return Encoded Base64 array
*/
public static String encode(byte[] binaryData) {
if (binaryData == null) {
return null;
}
int lengthDataBits = binaryData.length * EIGHTBIT;
if (lengthDataBits == 0) {
return "";
}
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1
: numberTriplets;
char encodedData[] = null;
encodedData = new char[numberQuartet * 4];
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
int encodedIndex = 0;
int dataIndex = 0;
if (fDebug) {
System.out.println("number of triplets = " + numberTriplets);
}
for (int i = 0; i < numberTriplets; i++) {
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
b3 = binaryData[dataIndex++];
if (fDebug) {
System.out.println("b1= " + b1 + ", b2= " + b2 + ", b3= " + b3);
}
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6)
: (byte) ((b3) >> 6 ^ 0xfc);
if (fDebug) {
System.out.println("val2 = " + val2);
System.out.println("k4 = " + (k << 4));
System.out.println("vak = " + (val2 | (k << 4)));
}
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
}
// form integral number of 6-bit groups
if (fewerThan24bits == EIGHTBIT) {
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
if (fDebug) {
System.out.println("b1=" + b1);
System.out.println("b1<<2 = " + (b1 >> 2));
}
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex++] = PAD;
encodedData[encodedIndex++] = PAD;
} else if (fewerThan24bits == SIXTEENBIT) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex++] = PAD;
}
return new String(encodedData);
}
/**
* Decodes Base64 data into octects
*
* @param encoded
* string containing Base64 data
* @return Array containind decoded data.
*/
public static byte[] decode(String encoded) {
if (encoded == null) {
return null;
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0) {
return null;// should be divisible by four
}
int numberQuadruple = (len / FOURBYTE);
if (numberQuadruple == 0) {
return new byte[0];
}
byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[(numberQuadruple) * 3];
for (; i < numberQuadruple - 1; i++) {
if (!isData((d1 = base64Data[dataIndex++]))
|| !isData((d2 = base64Data[dataIndex++]))
|| !isData((d3 = base64Data[dataIndex++]))
|| !isData((d4 = base64Data[dataIndex++]))) {
return null;
}// if found "no data" just return null
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
if (!isData((d1 = base64Data[dataIndex++]))
|| !isData((d2 = base64Data[dataIndex++]))) {
return null;// if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters
if (isPad(d3) && isPad(d4)) {
if ((b2 & 0xf) != 0)// last 4 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 1];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
return tmp;
} else if (!isPad(d3) && isPad(d4)) {
b3 = base64Alphabet[d3];
if ((b3 & 0x3) != 0)// last 2 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 2];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
return tmp;
} else {
return null;
}
} else { // No PAD e.g 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
return decodedData;
}
/**
* remove WhiteSpace from MIME containing encoded Base64 data.
*
* @param data
* the byte array of base64 data (with WS)
* @return the new length
*/
private static int removeWhiteSpace(char[] data) {
if (data == null) {
return 0;
}
// count characters that's not whitespace
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++) {
if (!isWhiteSpace(data[i])) {
data[newSize++] = data[i];
}
}
return newSize;
}
}

View File

@ -1,161 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
/**
* 工具类
*
*/
public class BaseHelper {
/**
* 流转字符串方法
*
* @param is
* @return
*/
public static String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
/**
* 显示dialog
*
* @param context
* 环境
* @param strTitle
* 标题
* @param strText
* 内容
* @param icon
* 图标
*/
public static void showDialog(Activity context, String strTitle,
String strText, int icon) {
AlertDialog.Builder tDialog = new AlertDialog.Builder(context);
tDialog.setIcon(icon);
tDialog.setTitle(strTitle);
tDialog.setMessage(strText);
tDialog.setPositiveButton("确定", null);
tDialog.show();
}
/**
* 打印信息
*
* @param tag
* 标签
* @param info
* 信息
*/
public static void log(String tag, String info) {
// Log.d(tag, info);
}
/**
* 获取权限
*
* @param permission
* 权限
* @param path
* 路径
*/
public static void chmod(String permission, String path) {
try {
String command = "chmod " + permission + " " + path;
Runtime runtime = Runtime.getRuntime();
runtime.exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
//
// show the progress bar.
/**
* 显示进度条
*
* @param context
* 环境
* @param title
* 标题
* @param message
* 信息
* @param indeterminate
* 确定性
* @param cancelable
* 可撤销
* @return
*/
public static ProgressDialog showProgress(Context context,
CharSequence title, CharSequence message, boolean indeterminate,
boolean cancelable) {
ProgressDialog dialog = new ProgressDialog(context);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setIndeterminate(indeterminate);
dialog.setCancelable(false);
// dialog.setDefaultButton(false);
dialog.setOnCancelListener(new IAPAlipay.AlixOnCancelListener(
(Activity) context));
dialog.show();
return dialog;
}
/**
* 字符串转json对象
* @param str
* @param split
* @return
*/
public static JSONObject string2JSON(String str, String split) {
JSONObject json = new JSONObject();
try {
String[] arrStr = str.split(split);
for (int i = 0; i < arrStr.length; i++) {
String[] arrKeyValue = arrStr[i].split("=");
json.put(arrKeyValue[0],
arrStr[i].substring(arrKeyValue[0].length() + 1));
}
}
catch (Exception e) {
e.printStackTrace();
}
return json;
}
}

View File

@ -1,344 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
public class IAPAlipay implements InterfaceIAP {
private static final String LOG_TAG = "IAPAlipay";
private static Activity mContext = null;
private static boolean bDebug = false;
private static Handler mHandler = null;
private static IAPAlipay mAdapter = null;
protected static void LogE(String msg, Exception e) {
Log.e(LOG_TAG, msg, e);
e.printStackTrace();
}
protected static void LogD(String msg) {
if (bDebug) {
Log.d(LOG_TAG, msg);
}
}
public IAPAlipay(Context context) {
mContext = (Activity) context;
mAdapter = this;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
initUIHandle();
}
});
}
@Override
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
LogD("initDeveloperInfo invoked " + cpInfo.toString());
try {
PartnerConfig.PARTNER = cpInfo.get("AlipayPartner");
PartnerConfig.SELLER = cpInfo.get("AlipaySeller");
PartnerConfig.RSA_PRIVATE = cpInfo.get("AlipayRsaPrivate");
PartnerConfig.RSA_ALIPAY_PUBLIC = cpInfo.get("AlipayPublic");
PartnerConfig.ALIPAY_PLUGIN_NAME = cpInfo.get("AlipayPluginName");
strPayAccount = cpInfo.get("AlipayRoyPayAccount");
strReceiveAccount = cpInfo.get("AlipayRoyReceiveAccount");
fPayPercent = ((cpInfo.get("AlipayRoyPercent") == null) ? 0.0f : Float.parseFloat(cpInfo.get("AlipayRoyPercent")));
strRoyTip = cpInfo.get("AlipayRoyTip");
strNotifyUrl = ((null == cpInfo.get("AlipayNotifyUrl")) ? "" : cpInfo.get("AlipayNotifyUrl"));
} catch (Exception e) {
LogE("Developer info is wrong!", e);
}
}
@Override
public void payForProduct(Hashtable<String, String> info) {
LogD("payForProduct invoked " + info.toString());
if (! networkReachable()) {
payResult(IAPWrapper.PAYRESULT_FAIL, "网络不可用");
return;
}
final Hashtable<String, String> productInfo = info;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
MobileSecurePayHelper mspHelper = new MobileSecurePayHelper(mContext);
boolean bInstalled = mspHelper.detectMobile_sp();
if (! bInstalled) {
payResult(IAPWrapper.PAYRESULT_FAIL, "未安装支付宝插件");
return;
}
// start pay for this order.
// 根据订单信息开始进行支付
try {
// prepare the order info.
// 准备订单信息
String orderInfo = getOrderInfo(productInfo);
// 这里根据签名方式对订单信息进行签名
String signType = getSignType();
String strsign = sign(signType, orderInfo);
// 对签名进行编码
strsign = URLEncoder.encode(strsign);
// 组装好参数
String info = orderInfo + "&sign=" + "\"" + strsign + "\"" + "&" + getSignType();
LogD("pay info : " + info);
// start the pay.
// 调用pay方法进行支付
MobileSecurePayer msp = new MobileSecurePayer();
boolean bRet = msp.pay(info, mHandler, AlixId.RQF_PAY, mContext);
if (bRet) {
// show the progress bar to indicate that we have started
// paying.
// 显示正在支付进度条
closeProgress();
mProgress = BaseHelper.showProgress(mContext, null, "正在支付", false, true);
} else {
payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败");
return;
}
} catch (Exception ex) {
LogE("Remote call failed", ex);
payResult(IAPWrapper.PAYRESULT_FAIL, "remote call failed");
return;
}
}
});
}
@Override
public void setDebugMode(boolean debug) {
bDebug = debug;
}
@Override
public String getSDKVersion() {
return "Unknown version";
}
static class AlixOnCancelListener implements DialogInterface.OnCancelListener {
Activity mcontext;
AlixOnCancelListener(Activity context) {
mcontext = context;
}
public void onCancel(DialogInterface dialog) {
mcontext.onKeyDown(KeyEvent.KEYCODE_BACK, null);
}
}
private static void initUIHandle() {
//
// the handler use to receive the pay result.
// 这里接收支付结果支付宝手机端同步通知
mHandler = new Handler() {
public void handleMessage(Message msg) {
try {
String strRet = (String) msg.obj;
LogD("handle msg : " + msg.toString());
switch (msg.what) {
case AlixId.RQF_PAY: {
LogD("msg.what is RQF_PAY");
mAdapter.closeProgress();
// 从通知中获取参数
try {
// 获取交易状态具体状态代码请参看文档
String memo = "memo=";
int imemoStart = strRet.indexOf("memo=");
imemoStart += memo.length();
int imemoEnd = strRet.indexOf(";result=");
memo = strRet.substring(imemoStart, imemoEnd);
// 对通知进行验签
ResultChecker resultChecker = new ResultChecker(strRet);
int retVal = resultChecker.checkSign();
// 返回验签结果以及交易状态
if (retVal == ResultChecker.RESULT_CHECK_SIGN_FAILED) {
payResult(IAPWrapper.PAYRESULT_FAIL, "签名验证失败");
} else if (retVal == ResultChecker.RESULT_CHECK_SIGN_SUCCEED && resultChecker.isPayOk()) {
payResult(IAPWrapper.PAYRESULT_SUCCESS, "支付成功");
} else {
payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败");
}
} catch (Exception e) {
e.printStackTrace();
payResult(IAPWrapper.PAYRESULT_FAIL, "结果解析失败");
}
}
break;
default:
mAdapter.closeProgress();
payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败");
break;
}
super.handleMessage(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
/**
* get the selected order info for pay. 获取商品订单信息
*
* @param position
* 商品在列表中的位置
* @return
*/
private static String strPayAccount = "";
private static String strReceiveAccount = "";
private static float fPayPercent = 0.0f;
private static String strRoyTip = "";
private static String strNotifyUrl = "";
private String getOrderInfo(Hashtable<String, String> info) {
String strRet = null;
try {
float price = Float.parseFloat(info.get("productPrice"));//IAPProducts.getProductPrice(productID);
String productName = info.get("productName");
String productDesc = info.get("productDesc");
String royParam = "";
if (fPayPercent > 0 ) {
float royValue = fPayPercent * price;
royParam = strPayAccount + "^" + strReceiveAccount + "^" + royValue + "^"+ strRoyTip;
royParam = "&royalty_parameters=\""+ royParam + "\"" + "&royalty_type=\"10" + "\"";
}
strRet = "partner=\"" + PartnerConfig.PARTNER + "\""
+ "&seller=\"" + PartnerConfig.SELLER + "\""
+ "&out_trade_no=\"" + getOutTradeNo() + "\""
+ "&subject=\"" + productName + "\""
+ "&body=\"" + productDesc + "\""
+ "&total_fee=\"" + price + "\""
+ "&notify_url=\"" + strNotifyUrl + "\""
+ royParam;
} catch (Exception e) {
LogE("Product info parse error", e);
}
LogD("order info : " + strRet);
return strRet;
}
/**
* get the out_trade_no for an order.
* 获取外部订单号
*
* @return
*/
String getOutTradeNo() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date();
String strKey = format.format(date);
java.util.Random r = new java.util.Random();
strKey = strKey + r.nextInt(10000);
return strKey;
}
//
//
/**
* sign the order info.
* 对订单信息进行签名
*
* @param signType 签名方式
* @param content 待签名订单信息
* @return
*/
private String sign(String signType, String content) {
LogD("sign params :");
LogD("type : " + signType + ", content : " + content + ", private : " + PartnerConfig.RSA_PRIVATE);
return Rsa.sign(content, PartnerConfig.RSA_PRIVATE);
}
/**
* get the sign type we use.
* 获取签名方式
*
* @return
*/
private String getSignType() {
String getSignType = "sign_type=" + "\"" + "RSA" + "\"";
return getSignType;
}
private ProgressDialog mProgress = null;
void closeProgress() {
try {
if (mProgress != null) {
mProgress.dismiss();
mProgress = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean networkReachable() {
boolean bRet = false;
try {
ConnectivityManager conn = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = conn.getActiveNetworkInfo();
bRet = (null == netInfo) ? false : netInfo.isAvailable();
} catch (Exception e) {
LogE("Fail to check network status", e);
}
LogD("NetWork reachable : " + bRet);
return bRet;
}
private static void payResult(int ret, String msg) {
IAPWrapper.onPayResult(mAdapter, ret, msg);
LogD("Alipay result : " + ret + " msg : " + msg);
}
@Override
public String getPluginVersion() {
return "0.2.0";
}
}

View File

@ -1,348 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
/**
* 检测安全支付服务是否正确安装如果没有安装进行本地安装或者下载安装 检测安全支付服务版本有新版本时进行下载
*
*/
public class MobileSecurePayHelper {
static final String TAG = "MobileSecurePayHelper";
private ProgressDialog mProgress = null;
Context mContext = null;
public MobileSecurePayHelper(Context context) {
this.mContext = context;
}
/**
* 检测安全支付服务是否安装
*
* @return
*/
public boolean detectMobile_sp() {
boolean isMobile_spExist = isMobile_spExist();
if (!isMobile_spExist) {
//
// get the cacheDir.
// 获取系统缓冲绝对路径 获取/data/data//cache目录
File cacheDir = mContext.getCacheDir();
final String cachePath = cacheDir.getAbsolutePath() + "/temp.apk";
//
// 捆绑安装
retrieveApkFromAssets(mContext, PartnerConfig.ALIPAY_PLUGIN_NAME,
cachePath);
mProgress = BaseHelper.showProgress(mContext, null, "正在检测安全支付服务版本",
false, true);
// 实例新线程检测是否有新版本进行下载
new Thread(new Runnable() {
public void run() {
//
// 检测是否有新的版本
PackageInfo apkInfo = getApkInfo(mContext, cachePath);
String newApkdlUrl = checkNewUpdate(apkInfo);
//
// 动态下载
if (newApkdlUrl != null)
retrieveApkFromNet(mContext, newApkdlUrl, cachePath);
// send the result back to caller.
// 发送结果
Message msg = new Message();
msg.what = AlixId.RQF_INSTALL_CHECK;
msg.obj = cachePath;
mHandler.sendMessage(msg);
}
}).start();
}
// else ok.
return isMobile_spExist;
}
/**
* 显示确认安装的提示
*
* @param context
* 上下文环境
* @param cachePath
* 安装文件路径
*/
public void showInstallConfirmDialog(final Context context,
final String cachePath) {
AlertDialog.Builder tDialog = new AlertDialog.Builder(context);
tDialog.setTitle("安装提示");
tDialog.setMessage("为保证您的交易安全,需要您安装支付宝安全支付服务,才能进行付款。\n\n点击确定立即安装。");
tDialog.setPositiveButton("确定",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//
// 修改apk权限
BaseHelper.chmod("777", cachePath);
//
// install the apk.
// 安装安全支付服务APK
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file://" + cachePath),
"application/vnd.android.package-archive");
context.startActivity(intent);
}
});
tDialog.setNegativeButton("取消",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
tDialog.show();
}
/**
* 遍历程序列表判断是否安装安全支付服务
*
* @return
*/
public boolean isMobile_spExist() {
PackageManager manager = mContext.getPackageManager();
List<PackageInfo> pkgList = manager.getInstalledPackages(0);
for (int i = 0; i < pkgList.size(); i++) {
PackageInfo pI = pkgList.get(i);
if (pI.packageName.equalsIgnoreCase("com.alipay.android.app"))
return true;
}
return false;
}
/**
* 安装安全支付服务安装assets文件夹下的apk
*
* @param context
* 上下文环境
* @param fileName
* apk名称
* @param path
* 安装路径
* @return
*/
public boolean retrieveApkFromAssets(Context context, String fileName,
String path) {
boolean bRet = false;
try {
InputStream is = context.getAssets().open(fileName);
File file = new File(path);
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
byte[] temp = new byte[1024];
int i = 0;
while ((i = is.read(temp)) > 0) {
fos.write(temp, 0, i);
}
fos.close();
is.close();
bRet = true;
} catch (IOException e) {
e.printStackTrace();
}
return bRet;
}
/**
* 获取未安装的APK信息
*
* @param context
* @param archiveFilePath
* APK文件的路径/sdcard/download/XX.apk
*/
public static PackageInfo getApkInfo(Context context, String archiveFilePath) {
PackageManager pm = context.getPackageManager();
PackageInfo apkInfo = pm.getPackageArchiveInfo(archiveFilePath,
PackageManager.GET_META_DATA);
return apkInfo;
}
/**
* 检查是否有新版本如果有返回apk下载地址
*
* @param packageInfo
* {@link PackageInfo}
* @return
*/
public String checkNewUpdate(PackageInfo packageInfo) {
String url = null;
try {
JSONObject resp = sendCheckNewUpdate(packageInfo.versionName);
// JSONObject resp = sendCheckNewUpdate("1.0.0");
if (resp.getString("needUpdate").equalsIgnoreCase("true")) {
url = resp.getString("updateUrl");
}
// else ok.
} catch (Exception e) {
e.printStackTrace();
}
return url;
}
/**
* 发送当前版本信息返回是否需要升级 如果需要升级返回更新apk地址
*
* @param versionName
* 当前版本号
* @return
*/
public JSONObject sendCheckNewUpdate(String versionName) {
JSONObject objResp = null;
try {
JSONObject req = new JSONObject();
req.put(AlixDefine.action, AlixDefine.actionUpdate);
JSONObject data = new JSONObject();
data.put(AlixDefine.platform, "android");
data.put(AlixDefine.VERSION, versionName);
data.put(AlixDefine.partner, "");
req.put(AlixDefine.data, data);
objResp = sendRequest(req.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return objResp;
}
/**
* 发送json数据
*
* @param content
* @return
*/
public final static String server_url = "https://msp.alipay.com/x.htm";
public JSONObject sendRequest(final String content) {
NetworkManager nM = new NetworkManager(this.mContext);
//
JSONObject jsonResponse = null;
try {
String response = null;
synchronized (nM) {
//
response = nM.SendAndWaitResponse(content, server_url);
}
jsonResponse = new JSONObject(response);
} catch (Exception e) {
e.printStackTrace();
}
//
if (jsonResponse != null)
BaseHelper.log(TAG, jsonResponse.toString());
return jsonResponse;
}
/**
* 动态下载apk
*
* @param context
* 上下文环境
* @param strurl
* 下载地址
* @param filename
* 文件名称
* @return
*/
public boolean retrieveApkFromNet(Context context, String strurl,
String filename) {
boolean bRet = false;
try {
NetworkManager nM = new NetworkManager(this.mContext);
bRet = nM.urlDownloadToFile(context, strurl, filename);
} catch (Exception e) {
e.printStackTrace();
}
return bRet;
}
//
// close the progress bar
void closeProgress() {
try {
if (mProgress != null) {
mProgress.dismiss();
mProgress = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
//
// the handler use to receive the install check result.
// 此处接收安装检测结果
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
try {
switch (msg.what) {
case AlixId.RQF_INSTALL_CHECK: {
//
closeProgress();
String cachePath = (String) msg.obj;
showInstallConfirmDialog(mContext, cachePath);
}
break;
}
super.handleMessage(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
};
}

View File

@ -1,175 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import com.alipay.android.app.IAlixPay;
import com.alipay.android.app.IRemoteServiceCallback;
/**
* 和安全支付服务通信发送订单信息进行支付接收支付宝返回信息
*
*/
public class MobileSecurePayer {
static String TAG = "MobileSecurePayer";
Integer lock = 0;
IAlixPay mAlixPay = null;
boolean mbPaying = false;
Activity mActivity = null;
// 和安全支付服务建立连接
private ServiceConnection mAlixPayConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
//
// wake up the binder to continue.
// 获得通信通道
synchronized (lock) {
mAlixPay = IAlixPay.Stub.asInterface(service);
lock.notify();
}
}
public void onServiceDisconnected(ComponentName className) {
mAlixPay = null;
}
};
/**
* 向支付宝发送支付请求
*
* @param strOrderInfo
* 订单信息
* @param callback
* 回调handler
* @param myWhat
* 回调信息
* @param activity
* 目标activity
* @return
*/
public boolean pay(final String strOrderInfo, final Handler callback,
final int myWhat, final Activity activity) {
if (mbPaying)
return false;
mbPaying = true;
//
mActivity = activity;
// bind the service.
// 绑定服务
if (mAlixPay == null) {
// 绑定安全支付服务需要获取上下文环境
// 如果绑定不成功使用mActivity.getApplicationContext().bindService
// 解绑时同理
mActivity.getApplicationContext().bindService(
new Intent(IAlixPay.class.getName()), mAlixPayConnection,
Context.BIND_AUTO_CREATE);
}
// else ok.
// 实例一个线程来进行支付
new Thread(new Runnable() {
public void run() {
try {
// wait for the service bind operation to completely
// finished.
// Note: this is important,otherwise the next mAlixPay.Pay()
// will fail.
// 等待安全支付服务绑定操作结束
// 注意这里很重要否则mAlixPay.Pay()方法会失败
synchronized (lock) {
if (mAlixPay == null)
lock.wait();
}
// register a Callback for the service.
// 为安全支付服务注册一个回调
mAlixPay.registerCallback(mCallback);
// call the MobileSecurePay service.
// 调用安全支付服务的pay方法
String strRet = mAlixPay.Pay(strOrderInfo);
BaseHelper.log(TAG, "After Pay: " + strRet);
// set the flag to indicate that we have finished.
// unregister the Callback, and unbind the service.
// 将mbPaying置为false表示支付结束
// 移除回调的注册解绑安全支付服务
mbPaying = false;
mAlixPay.unregisterCallback(mCallback);
mActivity.getApplicationContext().unbindService(
mAlixPayConnection);
// send the result back to caller.
// 发送交易结果
Message msg = new Message();
msg.what = myWhat;
msg.obj = strRet;
callback.sendMessage(msg);
} catch (Exception e) {
e.printStackTrace();
// send the result back to caller.
// 发送交易结果
Message msg = new Message();
msg.what = myWhat;
msg.obj = e.toString();
callback.sendMessage(msg);
}
}
}).start();
return true;
}
/**
* This implementation is used to receive callbacks from the remote service.
* 实现安全支付的回调
*/
private IRemoteServiceCallback mCallback = new IRemoteServiceCallback.Stub() {
/**
* This is called by the remote service regularly to tell us about new
* values. Note that IPC calls are dispatched through a thread pool
* running in each process, so the code executing here will NOT be
* running in our main thread like most other things -- so, to update
* the UI, we need to use a Handler to hop over there.
* 通过IPC机制启动安全支付服务
*/
public void startActivity(String packageName, String className,
int iCallingPid, Bundle bundle) throws RemoteException {
Intent intent = new Intent(Intent.ACTION_MAIN, null);
if (bundle == null)
bundle = new Bundle();
// else ok.
try {
bundle.putInt("CallingPid", iCallingPid);
intent.putExtras(bundle);
} catch (Exception e) {
e.printStackTrace();
}
intent.setClassName(packageName, className);
mActivity.startActivity(intent);
}
};
}

View File

@ -1,183 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* 网络连接工具类
*
*/
public class NetworkManager {
static final String TAG = "NetworkManager";
private int connectTimeout = 30 * 1000;
private int readTimeout = 30 * 1000;
Proxy mProxy = null;
Context mContext;
public NetworkManager(Context context) {
this.mContext = context;
setDefaultHostnameVerifier();
}
/**
* 检查代理是否cnwap接入
*/
private void detectProxy() {
ConnectivityManager cm = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni != null && ni.isAvailable()
&& ni.getType() == ConnectivityManager.TYPE_MOBILE) {
String proxyHost = android.net.Proxy.getDefaultHost();
int port = android.net.Proxy.getDefaultPort();
if (proxyHost != null) {
final InetSocketAddress sa = new InetSocketAddress(proxyHost,
port);
mProxy = new Proxy(Proxy.Type.HTTP, sa);
}
}
}
private void setDefaultHostnameVerifier() {
//
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
/**
* 发送和接收数据
*
* @param strReqData
* 请求数据
* @param strUrl
* 请求地址
* @return
*/
public String SendAndWaitResponse(String strReqData, String strUrl) {
//
detectProxy();
String strResponse = null;
ArrayList<BasicNameValuePair> pairs = new ArrayList<BasicNameValuePair>();
pairs.add(new BasicNameValuePair("requestData", strReqData));
HttpURLConnection httpConnect = null;
UrlEncodedFormEntity p_entity;
try {
p_entity = new UrlEncodedFormEntity(pairs, "utf-8");
URL url = new URL(strUrl);
if (mProxy != null) {
httpConnect = (HttpURLConnection) url.openConnection(mProxy);
} else {
httpConnect = (HttpURLConnection) url.openConnection();
}
httpConnect.setConnectTimeout(connectTimeout);
httpConnect.setReadTimeout(readTimeout);
httpConnect.setDoOutput(true);
httpConnect.addRequestProperty("Content-type",
"application/x-www-form-urlencoded;charset=utf-8");
httpConnect.connect();
OutputStream os = httpConnect.getOutputStream();
p_entity.writeTo(os);
os.flush();
InputStream content = httpConnect.getInputStream();
strResponse = BaseHelper.convertStreamToString(content);
BaseHelper.log(TAG, "response " + strResponse);
} catch (IOException e) {
e.printStackTrace();
} finally {
httpConnect.disconnect();
}
return strResponse;
}
/**
* 下载文件
*
* @param context
* 上下文环境
* @param strurl
* 下载地址
* @param path
* 下载路径
* @return
*/
public boolean urlDownloadToFile(Context context, String strurl, String path) {
boolean bRet = false;
//
detectProxy();
try {
URL url = new URL(strurl);
HttpURLConnection conn = null;
if (mProxy != null) {
conn = (HttpURLConnection) url.openConnection(mProxy);
} else {
conn = (HttpURLConnection) url.openConnection();
}
conn.setConnectTimeout(connectTimeout);
conn.setReadTimeout(readTimeout);
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
File file = new File(path);
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
byte[] temp = new byte[1024];
int i = 0;
while ((i = is.read(temp)) > 0) {
fos.write(temp, 0, i);
}
fos.close();
is.close();
bRet = true;
} catch (IOException e) {
e.printStackTrace();
}
return bRet;
}
}

View File

@ -1,16 +0,0 @@
package org.cocos2dx.plugin;
public class PartnerConfig {
// 合作商户ID用签约支付宝账号登录ms.alipay.com后在账户信息页面获取
public static String PARTNER = "";
// 商户收款的支付宝账号
public static String SELLER = "";
// 商户RSA私钥
public static String RSA_PRIVATE = "";
// 支付宝RSA公钥 用签约支付宝账号登录ms.alipay.com后在密钥管理页面获取
public static String RSA_ALIPAY_PUBLIC = "";
// 支付宝安全支付服务apk的名称必须与assets目录下的apk名称一致
public static String ALIPAY_PLUGIN_NAME = "";
}

View File

@ -1,109 +0,0 @@
package org.cocos2dx.plugin;
import org.json.JSONObject;
/**
* 对签名进行验签
*
*/
public class ResultChecker {
public static final int RESULT_INVALID_PARAM = 0;
public static final int RESULT_CHECK_SIGN_FAILED = 1;
public static final int RESULT_CHECK_SIGN_SUCCEED = 2;
String mContent;
public ResultChecker(String content) {
this.mContent = content;
}
/**
* 从验签内容中获取成功状态
*
* @return
*/
private String getSuccess() {
String success = null;
try {
JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";");
String result = objContent.getString("result");
result = result.substring(1, result.length() - 1);
JSONObject objResult = BaseHelper.string2JSON(result, "&");
success = objResult.getString("success");
success = success.replace("\"", "");
} catch (Exception e) {
e.printStackTrace();
}
return success;
}
/**
* 对签名进行验签
*
* @return
*/
int checkSign() {
int retVal = RESULT_CHECK_SIGN_SUCCEED;
try {
JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";");
String result = objContent.getString("result");
result = result.substring(1, result.length() - 1);
// 获取待签名数据
int iSignContentEnd = result.indexOf("&sign_type=");
String signContent = result.substring(0, iSignContentEnd);
// 获取签名
JSONObject objResult = BaseHelper.string2JSON(result, "&");
String signType = objResult.getString("sign_type");
signType = signType.replace("\"", "");
String sign = objResult.getString("sign");
sign = sign.replace("\"", "");
// 进行验签 返回验签结果
if (signType.equalsIgnoreCase("RSA")) {
if (!Rsa.doCheck(signContent, sign,
PartnerConfig.RSA_ALIPAY_PUBLIC))
retVal = RESULT_CHECK_SIGN_FAILED;
}
} catch (Exception e) {
retVal = RESULT_INVALID_PARAM;
e.printStackTrace();
}
return retVal;
}
int getResultStatus() {
int ret = 9000;
try {
JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";");
String result = objContent.getString("resultStatus");
result = result.substring(1, result.length() - 1);
ret = Integer.parseInt(result);
} catch (Exception e) {
e.printStackTrace();
ret = 4001;
}
return ret;
}
private static final int PAY_SUCCESS_STATUS_CODE = 9000;
public boolean isPayOk() {
boolean isPayOk = false;
String success = getSuccess();
if (success.equalsIgnoreCase("true") &&
checkSign() == RESULT_CHECK_SIGN_SUCCEED &&
PAY_SUCCESS_STATUS_CODE == getResultStatus())
{
isPayOk = true;
}
return isPayOk;
}
}

View File

@ -1,100 +0,0 @@
/*
* Copyright (C) 2010 The MobileSecurePay Project
* All right reserved.
* author: shiqun.shi@alipay.com
*/
package org.cocos2dx.plugin;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
/**
* RSA工具类
*
*/
public class Rsa {
// private static final String ALGORITHM = "RSA";
// private static PublicKey getPublicKeyFromX509(String algorithm,
// String bysKey) throws NoSuchAlgorithmException, Exception {
// byte[] decodedKey = Base64.decode(bysKey);
// X509EncodedKeySpec x509 = new X509EncodedKeySpec(decodedKey);
//
// KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
// return keyFactory.generatePublic(x509);
// }
// public static String encrypt(String content, String key) {
// try {
// PublicKey pubkey = getPublicKeyFromX509(ALGORITHM, key);
//
// Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
// cipher.init(Cipher.ENCRYPT_MODE, pubkey);
//
// byte plaintext[] = content.getBytes("UTF-8");
// byte[] output = cipher.doFinal(plaintext);
//
// String s = new String(Base64.encode(output));
//
// return s;
//
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
public static final String SIGN_ALGORITHMS = "SHA1WithRSA";
public static String sign(String content, String privateKey) {
String charset = "utf-8";
try {
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
Base64.decode(privateKey));
KeyFactory keyf = KeyFactory.getInstance("RSA");
PrivateKey priKey = keyf.generatePrivate(priPKCS8);
java.security.Signature signature = java.security.Signature
.getInstance(SIGN_ALGORITHMS);
signature.initSign(priKey);
signature.update(content.getBytes(charset));
byte[] signed = signature.sign();
return Base64.encode(signed);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static boolean doCheck(String content, String sign, String publicKey) {
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
byte[] encodedKey = Base64.decode(publicKey);
PublicKey pubKey = keyFactory
.generatePublic(new X509EncodedKeySpec(encodedKey));
java.security.Signature signature = java.security.Signature
.getInstance(SIGN_ALGORITHMS);
signature.initVerify(pubKey);
signature.update(content.getBytes("utf-8"));
boolean bverify = signature.verify(Base64.decode(sign));
return bverify;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="sdk/FlurryAgent.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginFlurry</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,9 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.libAnalyticsFlurry"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifestConfig xmlns:android="http://schemas.android.com/apk/res/android">
<applicationCfg keyword="com.flurry.android.FlurryFullscreenTakeoverActivity">
<activity android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode"
android:hardwareAccelerated="false" >
</activity>
</applicationCfg>
<permissionCfg>
<uses-permission android:name="android.permission.INTERNET" />
</permissionCfg>
</manifestConfig>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="libPluginFlurry" default="plugin-publish">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />
</project>

View File

@ -1,16 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-7
android.library=true
android.library.reference.1=../../../protocols/proj.android

View File

@ -1 +0,0 @@
9076d822b8a15910bd7053ecb2651c84ce98c726

View File

@ -1,252 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import com.flurry.android.FlurryAdListener;
import com.flurry.android.FlurryAdSize;
import com.flurry.android.FlurryAdType;
import com.flurry.android.FlurryAds;
import com.flurry.android.FlurryAgent;
public class AdsFlurry implements InterfaceAds, FlurryAdListener {
private Context mContext = null;
protected static String TAG = "AdsFlurry";
private FrameLayout mBannerView = null;
private WindowManager mWm = null;
private AdsFlurry mAdapter = null;
protected static void LogE(String msg, Exception e) {
Log.e(TAG, msg, e);
e.printStackTrace();
}
private static boolean isDebug = false;
protected static void LogD(String msg) {
if (isDebug) {
Log.d(TAG, msg);
}
}
public AdsFlurry(Context context) {
mContext = context;
mAdapter = this;
}
@Override
public void setDebugMode(boolean isDebugMode) {
isDebug = isDebugMode;
final boolean curDebug = isDebug;
PluginWrapper.runOnMainThread(new Runnable(){
@Override
public void run() {
FlurryAgent.setLogEnabled(curDebug);
if (curDebug) {
FlurryAgent.setLogLevel(Log.DEBUG);
}
}
});
}
@Override
public String getSDKVersion() {
return "3.2.1";
}
@Override
public String getPluginVersion() {
return "0.2.0";
}
@Override
public void configDeveloperInfo(Hashtable<String, String> devInfo) {
final Hashtable<String, String> curInfo = devInfo;
PluginWrapper.runOnMainThread(new Runnable(){
@Override
public void run() {
try {
String appKey = curInfo.get("FlurryAppKey");
FlurryAgent.onStartSession(mContext, appKey);
FlurryAds.setAdListener(mAdapter);
FlurryAds.initializeAds(mContext);
} catch (Exception e) {
LogE("Error during configDeveloperInfo.", e);
}
}
});
}
@Override
public void showAds(Hashtable<String, String> adsInfo, int pos) {
final Hashtable<String, String> curInfo = adsInfo;
final int curPos = pos;
PluginWrapper.runOnMainThread(new Runnable(){
@Override
public void run() {
try
{
String spaceID = curInfo.get("FlurryAdsID");
if (null == spaceID || TextUtils.isEmpty(spaceID))
{
LogD("Value of 'FlurryAdsID' should not be empty");
return;
}
String strSize = curInfo.get("FlurryAdsSize");
int size = Integer.parseInt(strSize);
if (size != 1 && size != 2 && size != 3) {
LogD("Valur of 'FlurryAdsSize' should be one of '1', '2', '3'");
return;
}
FlurryAdSize eSize = FlurryAdSize.BANNER_TOP;
switch (size)
{
case 1:
eSize = FlurryAdSize.BANNER_TOP;
break;
case 2:
eSize = FlurryAdSize.BANNER_BOTTOM;
break;
case 3:
eSize = FlurryAdSize.FULLSCREEN;
break;
default:
break;
}
if (null == mWm) {
mWm = (WindowManager) mContext.getSystemService("window");
}
if (null != mBannerView) {
mWm.removeView(mBannerView);
mBannerView = null;
}
mBannerView = new FrameLayout(mContext);
AdsWrapper.addAdView(mWm, mBannerView, curPos);
FlurryAds.fetchAd(mContext, spaceID, mBannerView, eSize);
} catch (Exception e) {
LogE("Error during showAds", e);
}
}
});
}
@Override
public void hideAds(Hashtable<String, String> adsInfo) {
final Hashtable<String, String> curInfo = adsInfo;
PluginWrapper.runOnMainThread(new Runnable(){
@Override
public void run() {
try
{
String spaceID = curInfo.get("FlurryAdsID");
if (null == spaceID || TextUtils.isEmpty(spaceID))
{
LogD("Value of 'FlurryAdsID' should not be empty");
return;
}
FlurryAds.removeAd(mContext, spaceID, (ViewGroup) mBannerView);
} catch (Exception e) {
LogE("Error during hideAds", e);
}
}
});
}
@Override
public void queryPoints() {
// TODO Auto-generated method stub
}
@Override
public void spendPoints(int points) {
// TODO Auto-generated method stub
}
@Override
public void onAdClicked(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAdClosed(String arg0) {
AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads will be dismissed");
}
@Override
public void onAdOpened(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onApplicationExit(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onRenderFailed(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onVideoCompleted(String arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean shouldDisplayAd(String arg0, FlurryAdType arg1) {
AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsShown, "Ads will be shown");
return true;
}
@Override
public void spaceDidFailToReceiveAd(String arg0) {
LogD("param : " + arg0);
AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_UnknownError, "Failed to receive Ads of flurry");
}
@Override
public void spaceDidReceiveAd(String arg0) {
AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsReceived, "Ads of flurry received");
}
}

View File

@ -1,339 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;
import java.util.Iterator;
import org.json.JSONObject;
import android.content.Context;
import android.util.Log;
import com.flurry.android.Constants;
import com.flurry.android.FlurryAgent;
public class AnalyticsFlurry implements InterfaceAnalytics {
private Context mContext = null;
protected static String TAG = "AnalyticsFlurry";
protected static void LogE(String msg, Exception e) {
Log.e(TAG, msg, e);
e.printStackTrace();
}
private static boolean isDebug = false;
protected static void LogD(String msg) {
if (isDebug) {
Log.d(TAG, msg);
}
}
public AnalyticsFlurry(Context context) {
mContext = context;
}
@Override
public void startSession(String appKey) {
LogD("startSession invoked!");
final String curKey = appKey;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
FlurryAgent.onStartSession(mContext, curKey);
}
});
}
@Override
public void stopSession() {
LogD("stopSession invoked!");
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.onEndSession(mContext);
}
});
}
@Override
public void setSessionContinueMillis(int millis) {
LogD("setSessionContinueMillis invoked!");
final int curMillis = millis;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.setContinueSessionMillis(curMillis);
}
});
}
@Override
public void setCaptureUncaughtException(boolean isEnabled) {
LogD("setCaptureUncaughtException invoked!");
final boolean curEnable = isEnabled;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.setCaptureUncaughtExceptions(curEnable);
}
});
}
@Override
public void setDebugMode(boolean isDebugMode) {
isDebug = isDebugMode;
final boolean curDebugMode = isDebug;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.setLogEnabled(curDebugMode);
if (curDebugMode) {
FlurryAgent.setLogLevel(Log.DEBUG);
}
}
});
}
@Override
public void logError(String errorId, String message) {
LogD("logError invoked!");
final String curID = errorId;
final String curMsg = message;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.onError(curID, curMsg, "");
}
});
}
@Override
public void logEvent(String eventId) {
LogD("logEvent(eventId) invoked!");
final String curId = eventId;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.logEvent(curId);
}
});
}
@Override
public void logEvent(String eventId, Hashtable<String, String> paramMap) {
LogD("logEvent(eventId, paramMap) invoked!");
final String curId = eventId;
final Hashtable<String, String> curParam = paramMap;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.logEvent(curId, curParam);
}
});
}
@Override
public void logTimedEventBegin(String eventId) {
LogD("logTimedEventBegin invoked!");
final String curId = eventId;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.logEvent(curId, true);
}
});
}
@Override
public void logTimedEventEnd(String eventId) {
LogD("logTimedEventEnd invoked!");
final String curId = eventId;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
FlurryAgent.endTimedEvent(curId);
}
});
}
@Override
public String getSDKVersion() {
return "3.2.1";
}
protected void logTimedEventBeginWithParams(JSONObject eventInfo) {
LogD("logTimedEventBegin invoked!");
final JSONObject curInfo = eventInfo;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try{
String eventId = curInfo.getString("Param1");
if (curInfo.has("Param2"))
{
JSONObject params = curInfo.getJSONObject("Param2");
@SuppressWarnings("rawtypes")
Iterator it = params.keys();
Hashtable<String, String> paramMap = new Hashtable<String, String>();
while (it.hasNext()) {
String key = (String) it.next();
String value = params.getString(key);
paramMap.put(key, value);
}
FlurryAgent.logEvent(eventId, paramMap, true);
} else {
FlurryAgent.logEvent(eventId, true);
}
} catch(Exception e){
LogE("Exception in logTimedEventBegin", e);
}
}
});
}
protected void setReportLocation(boolean enabled) {
LogD("setReportLocation invoked!");
final boolean curEnable = enabled;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try{
FlurryAgent.setReportLocation(curEnable);
} catch(Exception e){
LogE("Exception in setReportLocation", e);
}
}
});
}
protected void logPageView() {
LogD("logPageView invoked!");
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try{
FlurryAgent.onPageView();
} catch(Exception e){
LogE("Exception in logPageView", e);
}
}
});
}
protected void setVersionName(String versionName) {
LogD("setVersionName invoked!");
final String curVer = versionName;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
FlurryAgent.setVersionName(curVer);
} catch(Exception e){
LogE("Exception in setVersionName", e);
}
}
});
}
protected void setAge(int age) {
LogD("setAge invoked!");
final int curAge = age;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
FlurryAgent.setAge(curAge);
} catch(Exception e){
LogE("Exception in setAge", e);
}
}
});
}
protected void setGender(int gender) {
LogD("setGender invoked!");
final int curGender = gender;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
byte bGender;
if (1 == curGender) {
bGender = Constants.MALE;
} else {
bGender = Constants.FEMALE;
}
FlurryAgent.setGender(bGender);
} catch(Exception e){
LogE("Exception in setGender", e);
}
}
});
}
protected void setUserId(String userId) {
LogD("setUserId invoked!");
final String curUser = userId;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
FlurryAgent.setUserId(curUser);
} catch(Exception e){
LogE("Exception in setUserId", e);
}
}
});
}
protected void setUseHttps(boolean useHttps) {
LogD("setUseHttps invoked!");
final boolean curCfg = useHttps;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
FlurryAgent.setUseHttps(curCfg);
} catch(Exception e){
LogE("Exception in setUseHttps", e);
}
}
});
}
@Override
public String getPluginVersion() {
return "0.2.0";
}
}

View File

@ -1,53 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "InterfaceAds.h"
#import "FlurryAdDelegate.h"
@interface AdsFlurry : NSObject <InterfaceAds, FlurryAdDelegate>
{
}
@property BOOL debug;
/**
interfaces of protocol : InterfaceAds
*/
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
- (void) showAds: (NSMutableDictionary*) info position:(int) pos;
- (void) hideAds: (NSMutableDictionary*) info;
- (void) queryPoints;
- (void) spendPoints: (int) points;
- (void) setDebugMode: (BOOL) isDebugMode;
- (NSString*) getSDKVersion;
- (NSString*) getPluginVersion;
/**
interfaces of protocol : FlurryAdDelegate
*/
- (void) spaceDidReceiveAd:(NSString*)adSpace;
- (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error;
- (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial;
@end

View File

@ -1,139 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "AdsFlurry.h"
#import "Flurry.h"
#import "FlurryAds.h"
#import "AdsWrapper.h"
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
@implementation AdsFlurry
@synthesize debug = __debug;
#pragma mark Interfaces for ProtocolAds impl
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo
{
NSString* appKey = [devInfo objectForKey:@"FlurryAppKey"];
if (appKey) {
[Flurry startSession:appKey];
}
[FlurryAds initialize:[AdsWrapper getCurrentRootViewController]];
[FlurryAds setAdDelegate:self];
}
- (void) showAds: (NSMutableDictionary*) info position:(int) pos
{
NSString* strSpaceID = [info objectForKey:@"FlurryAdsID"];
if (! strSpaceID || [strSpaceID length] == 0) {
OUTPUT_LOG(@"Value of 'FlurryAdsID' should not be empty");
return;
}
NSString* strSize = [info objectForKey:@"FlurryAdsSize"];
int size = [strSize intValue];
if (size != 1 && size != 2 && size != 3) {
OUTPUT_LOG(@"Value of 'FlurryAdsSize' should be one of '1', '2', '3' ");
return;
}
UIViewController* controller = [AdsWrapper getCurrentRootViewController];
if (controller) {
[FlurryAds fetchAndDisplayAdForSpace:strSpaceID view:controller.view size:size];
}
}
- (void) hideAds: (NSMutableDictionary*) info
{
NSString* strSpaceID = [info objectForKey:@"FlurryAdsID"];
if (! strSpaceID || [strSpaceID length] == 0) {
OUTPUT_LOG(@"Value of 'FlurryAdsID' should not be empty");
return;
}
[FlurryAds removeAdFromSpace:strSpaceID];
}
- (void) queryPoints
{
}
- (void) spendPoints: (int) points
{
}
- (void) setDebugMode: (BOOL) isDebugMode
{
OUTPUT_LOG(@"Flurry setDebugMode invoked(%d)", isDebugMode);
self.debug = isDebugMode;
[Flurry setDebugLogEnabled:isDebugMode];
if (self.debug) {
[FlurryAds enableTestAds:YES];
}
}
- (NSString*) getSDKVersion
{
return @"4.2.1";
}
- (NSString*) getPluginVersion
{
return @"0.2.0";
}
#pragma mark Interfaces for FlurryAdDelegate impl
- (void) spaceDidReceiveAd:(NSString*)adSpace
{
[AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"Ads of flurry received"];
}
- (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error
{
NSString* strMsg = [[error userInfo] objectForKey:@"NSLocalizedDescription"];
if (! strMsg) {
strMsg = @"Failed to receive ads";
}
[AdsWrapper onAdsResult:self withRet:kUnknownError withMsg:strMsg];
}
- (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial
{
[AdsWrapper onAdsResult:self withRet:kAdsShown withMsg:@"Ads will be shown"];
return YES;
}
- (void) spaceWillDismiss:(NSString *)adSpace
{
[AdsWrapper onAdsResult:self withRet:kAdsDismissed withMsg:@"Ads will be dismissed"];
}
@end

View File

@ -1,61 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "InterfaceAnalytics.h"
@interface AnalyticsFlurry : NSObject <InterfaceAnalytics>
{
}
@property BOOL debug;
/**
interfaces of protocol : InterfaceAnalytics
*/
- (void) startSession: (NSString*) appKey;
- (void) stopSession;
- (void) setSessionContinueMillis: (long) millis;
- (void) setCaptureUncaughtException: (BOOL) isEnabled;
- (void) setDebugMode: (BOOL) isDebugMode;
- (void) logError: (NSString*) errorId withMsg:(NSString*) message;
- (void) logEvent: (NSString*) eventId;
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
- (void) logTimedEventBegin: (NSString*) eventId;
- (void) logTimedEventEnd: (NSString*) eventId;
- (NSString*) getSDKVersion;
- (NSString*) getPluginVersion;
/**
interfaces of flurry SDK
*/
- (void) setAge: (NSNumber*) age;
- (void) setGender: (NSNumber*) gender;
- (void) setUserId: (NSString*) userId;
- (void) setUseHttps: (NSNumber*) enabled;
- (void) logPageView;
- (void) setVersionName: (NSString*) versionName;
- (void) logTimedEventBeginWithParams: (NSMutableDictionary*) params;
- (void) logTimedEventEndWithParams: (NSMutableDictionary*) params;
@end

View File

@ -1,173 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "AnalyticsFlurry.h"
#import "Flurry.h"
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
@implementation AnalyticsFlurry
@synthesize debug = __debug;
- (void) startSession: (NSString*) appKey
{
[Flurry startSession:appKey];
}
- (void) stopSession
{
OUTPUT_LOG(@"Flurry stopSession in flurry not available on iOS");
}
- (void) setSessionContinueMillis: (long) millis
{
OUTPUT_LOG(@"Flurry setSessionContinueMillis invoked(%ld)", millis);
int seconds = (int)(millis / 1000);
[Flurry setSessionContinueSeconds:seconds];
}
- (void) setCaptureUncaughtException: (BOOL) isEnabled
{
OUTPUT_LOG(@"Flurry setCaptureUncaughtException in flurry not available on iOS");
}
- (void) setDebugMode: (BOOL) isDebugMode
{
OUTPUT_LOG(@"Flurry setDebugMode invoked(%d)", isDebugMode);
self.debug = isDebugMode;
[Flurry setDebugLogEnabled:isDebugMode];
}
- (void) logError: (NSString*) errorId withMsg:(NSString*) message
{
OUTPUT_LOG(@"Flurry logError invoked(%@, %@)", errorId, message);
NSString* msg = nil;
if (nil == message) {
msg = @"";
} else {
msg = message;
}
[Flurry logError:errorId message:msg exception:nil];
}
- (void) logEvent: (NSString*) eventId
{
OUTPUT_LOG(@"Flurry logEvent invoked(%@)", eventId);
[Flurry logEvent:eventId];
}
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
{
OUTPUT_LOG(@"Flurry logEventWithParams invoked (%@, %@)", eventId, [paramMap debugDescription]);
[Flurry logEvent:eventId withParameters:paramMap];
}
- (void) logTimedEventBegin: (NSString*) eventId
{
OUTPUT_LOG(@"Flurry logTimedEventBegin invoked (%@)", eventId);
[Flurry logEvent:eventId timed:YES];
}
- (void) logTimedEventEnd: (NSString*) eventId
{
OUTPUT_LOG(@"Flurry logTimedEventEnd invoked (%@)", eventId);
[Flurry endTimedEvent:eventId withParameters:nil];
}
- (NSString*) getSDKVersion
{
return @"4.2.1";
}
- (NSString*) getPluginVersion
{
return @"0.2.0";
}
- (void) setAge: (NSNumber*) age
{
int nAge = [age integerValue];
OUTPUT_LOG(@"Flurry setAge invoked (%d)", nAge);
[Flurry setAge:nAge];
}
- (void) setGender: (NSNumber*) gender
{
OUTPUT_LOG(@"Flurry setGender invoked (%@)", gender);
int nValue = [gender intValue];
NSString* strGender;
if (nValue == 1) {
strGender = @"m";
} else {
strGender = @"f";
}
[Flurry setGender:strGender];
}
- (void) setUserId: (NSString*) userId
{
OUTPUT_LOG(@"Flurry setUserId invoked (%@)", userId);
[Flurry setUserID:userId];
}
- (void) setUseHttps: (NSNumber*) enabled
{
BOOL bEnabled = [enabled boolValue];
OUTPUT_LOG(@"Flurry setUseHttps invoked (%@)", enabled);
[Flurry setSecureTransportEnabled:bEnabled];
}
- (void) logPageView
{
OUTPUT_LOG(@"Flurry logPageView invoked");
[Flurry logPageView];
}
- (void) setVersionName: (NSString*) versionName
{
OUTPUT_LOG(@"Flurry setVersionName invoked (%@)", versionName);
[Flurry setAppVersion:versionName];
}
- (void) logTimedEventBeginWithParams: (NSMutableDictionary*) paramMap
{
OUTPUT_LOG(@"Flurry logTimedEventBeginWithParams invoked (%@)", [paramMap debugDescription]);
NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"];
NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"];
if (params) {
[Flurry logEvent:eventId withParameters:paramMap timed:YES];
} else {
[Flurry logEvent:eventId timed:YES];
}
}
- (void) logTimedEventEndWithParams: (NSMutableDictionary*) paramMap
{
OUTPUT_LOG(@"Flurry logTimedEventEndWithParams invoked (%@)", [paramMap debugDescription]);
NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"];
NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"];
[Flurry endTimedEvent:eventId withParameters:params];
}
@end

View File

@ -1,677 +0,0 @@
//
// Flurry.h
// Flurry iOS Analytics Agent
//
// Copyright 2009-2012 Flurry, Inc. All rights reserved.
//
// Methods in this header file are for use with Flurry Analytics
#import <UIKit/UIKit.h>
/*!
* @brief Provides all available methods for defining and reporting Analytics from use
* of your app.
*
* Set of methods that allow developers to capture detailed, aggregate information
* regarding the use of their app by end users.
*
* @note This class provides methods necessary for correct function of FlurryAds.h.
* For information on how to use Flurry's Ads SDK to
* attract high-quality users and monetize your user base see <a href="http://support.flurry.com/index.php?title=Publishers">Support Center - Publishers</a>.
*
* @author 2009 - 2012 Flurry, Inc. All Rights Reserved.
* @version 4.2.0
*
*/
@interface Flurry : NSObject {
}
/** @name Pre-Session Calls
* Optional sdk settings that should be called before start session.
*/
//@{
/*!
* @brief Explicitly specifies the App Version that Flurry will use to group Analytics data.
* @since 2.7
*
* This is an optional method that overrides the App Version Flurry uses for reporting. Flurry will
* use the CFBundleVersion in your info.plist file when this method is not invoked.
*
* @note There is a maximum of 605 versions allowed for a single app. \n
* This method must be called prior to invoking #startSession:.
*
* @param version The custom version name.
*/
+ (void)setAppVersion:(NSString *)version;
/*!
* @brief Retrieves the Flurry Agent Build Version.
* @since 2.7
*
* This is an optional method that retrieves the Flurry Agent Version the app is running under.
* It is most often used if reporting an unexpected behavior of the SDK to <a href="mailto:iphonesupport@flurry.com">
* Flurry Support</a>
*
* @note This method must be called prior to invoking #startSession:. \n
* FAQ for the iPhone SDK is located at <a href="http://wiki.flurry.com/index.php?title=IPhone_FAQ">
* Support Center - iPhone FAQ</a>.
*
* @see #setDebugLogEnabled: for information on how to view debugging information on your console.
*
* @return The agent version of the Flurry SDK.
*
*/
+ (NSString *)getFlurryAgentVersion;
/*!
* @brief Displays an exception in the debug log if thrown during a Session.
* @since 2.7
*
* This is an optional method that augments the debug logs with exceptions that occur during the session.
* You must both capture exceptions to Flurry and set debug logging to enabled for this method to
* display information to the console. The default setting for this method is @c NO.
*
* @note This method must be called prior to invoking #startSession:.
*
* @see #setDebugLogEnabled: for information on how to view debugging information on your console. \n
* #logError:message:exception: for details on logging exceptions. \n
* #logError:message:error: for details on logging errors.
*
* @param value @c YES to show errors in debug logs, @c NO to omit errors in debug logs.
*/
+ (void)setShowErrorInLogEnabled:(BOOL)value;
/*!
* @brief Generates debug logs to console.
* @since 2.7
*
* This is an optional method that displays debug information related to the Flurry SDK.
* display information to the console. The default setting for this method is @c NO.
*
* @note This method must be called prior to invoking #startSession:.
*
* @param value @c YES to show debug logs, @c NO to omit debug logs.
*
*/
+ (void)setDebugLogEnabled:(BOOL)value;
/*!
* @brief Set the timeout for expiring a Flurry session.
* @since 2.7
*
* This is an optional method that sets the time the app may be in the background before
* starting a new session upon resume. The default value for the session timeout is 10
* seconds in the background.
*
* @note This method must be called prior to invoking #startSession:.
*
* @param seconds The time in seconds to set the session timeout to.
*/
+ (void)setSessionContinueSeconds:(int)seconds;
/*!
* @brief Send data over a secure transport.
* @since 3.0
*
* This is an optional method that sends data over an SSL connection when enabled. The
* default value is @c NO.
*
* @note This method must be called prior to invoking #startSession:.
*
* @param value @c YES to send data over secure connection.
*/
+ (void)setSecureTransportEnabled:(BOOL)value;
/*!
* @brief Enable automatic collection of crash reports.
* @since 4.1
*
* This is an optional method that collects crash reports when enabled. The
* default value is @c NO.
*
* @note This method must be called prior to invoking #startSession:.
*
* @param value @c YES to enable collection of crash reports.
*/
+ (void)setCrashReportingEnabled:(BOOL)value;
//@}
/*!
* @brief Start a Flurry session for the project denoted by @c apiKey.
* @since 2.6
*
* This method serves as the entry point to Flurry Analytics collection. It must be
* called in the scope of @c applicationDidFinishLaunching. The session will continue
* for the period the app is in the foreground until your app is backgrounded for the
* time specified in #setSessionContinueSeconds:. If the app is resumed in that period
* the session will continue, otherwise a new session will begin.
*
* Crash reporting will not be enabled. See #startSession:enableCrashReporting: for
* more information.
*
* @note If testing on a simulator, please be sure to send App to background via home
* button. Flurry depends on the iOS lifecycle to be complete for full reporting.
*
* @see #setSessionContinueSeconds: for details on setting a custom session timeout.
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
// ....
}
* @endcode
*
* @param apiKey The API key for this project.
*/
+ (void)startSession:(NSString *)apiKey;
/*!
* @brief Start a Flurry session for the project denoted by @c apiKey.
* @since 4.0.8
*
* This method serves as the entry point to Flurry Analytics collection. It must be
* called in the scope of @c applicationDidFinishLaunching passing in the launchOptions param.
* The session will continue
* for the period the app is in the foreground until your app is backgrounded for the
* time specified in #setSessionContinueSeconds:. If the app is resumed in that period
* the session will continue, otherwise a new session will begin.
*
* @note If testing on a simulator, please be sure to send App to background via home
* button. Flurry depends on the iOS lifecycle to be complete for full reporting.
*
* @see #setSessionContinueSeconds: for details on setting a custom session timeout.
*
* @code
* - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY" withOptions:launchOptions];
// ....
}
* @endcode
*
* @param apiKey The API key for this project.
* @param options passed launchOptions from the applicatin's didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
*/
+ (void) startSession:(NSString *)apiKey withOptions:(id)options;
/** @name Event and Error Logging
* Methods for reporting custom events and errors during the session.
*/
//@{
/*!
* @brief Records a custom event specified by @c eventName.
* @since 2.8.4
*
* This method allows you to specify custom events within your app. As a general rule
* you should capture events related to user navigation within your app, any action
* around monetization, and other events as they are applicable to tracking progress
* towards your business goals.
*
* @note You should not pass private or confidential information about your users in a
* custom event. \n
* Where applicable, you should make a concerted effort to use timed events with
* parameters (#logEvent:withParameters:timed:) or events with parameters
* (#logEvent:withParameters:). This provides valuable information around the time the user
* spends within an action (e.g. - time spent on a level or viewing a page) or characteristics
* of an action (e.g. - Buy Event that has a Parameter of Widget with Value Golden Sword).
*
* @see #logEvent:withParameters: for details on storing events with parameters. \n
* #logEvent:timed: for details on storing timed events. \n
* #logEvent:withParameters:timed: for details on storing timed events with parameters. \n
* #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating
* parameters.
*
* @code
* - (void)interestingAppAction
{
[Flurry logEvent:@"Interesting_Action"];
// Perform interesting action
}
* @endcode
*
* @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme
* that can be easily understood by non-technical people in your business domain.
*/
+ (void)logEvent:(NSString *)eventName;
/*!
* @brief Records a custom parameterized event specified by @c eventName with @c parameters.
* @since 2.8.4
*
* This method overrides #logEvent to allow you to associate parameters with an event. Parameters
* are extremely valuable as they allow you to store characteristics of an action. For example,
* if a user purchased an item it may be helpful to know what level that user was on.
* By setting this parameter you will be able to view a distribution of levels for the purcahsed
* event on the <a href="http://dev.flurry.com">Flurrly Dev Portal</a>.
*
* @note You should not pass private or confidential information about your users in a
* custom event. \n
* A maximum of 10 parameter names may be associated with any event. Sending
* over 10 parameter names with a single event will result in no parameters being logged
* for that event. You may specify an infinite number of Parameter values. For example,
* a Search Box would have 1 parameter name (e.g. - Search Box) and many values, which would
* allow you to see what values users look for the most in your app. \n
* Where applicable, you should make a concerted effort to use timed events with
* parameters (#logEvent:withParameters:timed:). This provides valuable information
* around the time the user spends within an action (e.g. - time spent on a level or
* viewing a page).
*
* @see #logEvent:withParameters:timed: for details on storing timed events with parameters. \n
* #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating
* parameters.
*
* @code
* - (void)userPurchasedSomethingCool
{
NSDictionary *params =
[NSDictionary dictionaryWithObjectsAndKeys:@"Cool Item", // Parameter Value
@"Item Purchased", // Parameter Name
nil];
[Flurry logEvent:@"Something Cool Purchased" withParameters:params];
// Give user cool item
}
* @endcode
*
* @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme
* that can be easily understood by non-technical people in your business domain.
* @param parameters A map containing Name-Value pairs of parameters.
*/
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters;
/*!
* @brief Records an app exception. Commonly used to catch unhandled exceptions.
* @since 2.7
*
* This method captures an exception for reporting to Flurry. We recommend adding an uncaught
* exception listener to capture any exceptions that occur during usage that is not
* anticipated by your app.
*
* @see #logError:message:error: for details on capturing errors.
*
* @code
* - (void) uncaughtExceptionHandler(NSException *exception)
{
[Flurry logError:@"Uncaught" message:@"Crash!" exception:exception];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
[Flurry startSession:@"YOUR_API_KEY"];
// ....
}
* @endcode
*
* @param errorID Name of the error.
* @param message The message to associate with the error.
* @param exception The exception object to report.
*/
+ (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception;
/*!
* @brief Records an app error.
* @since 2.7
*
* This method captures an error for reporting to Flurry.
*
* @see #logError:message:exception: for details on capturing exceptions.
*
* @code
* - (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[Flurry logError:@"WebView No Load" message:[error localizedDescription] error:error];
}
* @endcode
*
* @param errorID Name of the error.
* @param message The message to associate with the error.
* @param error The error object to report.
*/
+ (void)logError:(NSString *)errorID message:(NSString *)message error:(NSError *)error;
/*!
* @brief Records a timed event specified by @c eventName.
* @since 2.8.4
*
* This method overrides #logEvent to allow you to capture the length of an event. This can
* be extremely valuable to understand the level of engagement with a particular action. For
* example, you can capture how long a user spends on a level or reading an article.
*
* @note You should not pass private or confidential information about your users in a
* custom event. \n
* Where applicable, you should make a concerted effort to use parameters with your timed
* events (#logEvent:withParameters:timed:). This provides valuable information
* around the characteristics of an action (e.g. - Buy Event that has a Parameter of Widget with
* Value Golden Sword).
*
* @see #logEvent:withParameters:timed: for details on storing timed events with parameters. \n
* #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating
* parameters.
*
* @code
* - (void)startLevel
{
[Flurry logEvent:@"Level Played" timed:YES];
// Start user on level
}
- (void)endLevel
{
[Flurry endTimedEvent:@"Level Played" withParameters:nil];
// User done with level
}
* @endcode
*
* @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme
* that can be easily understood by non-technical people in your business domain.
* @param timed Specifies the event will be timed.
*/
+ (void)logEvent:(NSString *)eventName timed:(BOOL)timed;
/*!
* @brief Records a custom parameterized timed event specified by @c eventName with @c parameters.
* @since 2.8.4
*
* This method overrides #logEvent to allow you to capture the length of an event with parameters.
* This can be extremely valuable to understand the level of engagement with a particular action
* and the characteristics associated with that action. For example, you can capture how long a user
* spends on a level or reading an article. Parameters can be used to capture, for example, the
* author of an article or if something was purchased while on the level.
*
* @note You should not pass private or confidential information about your users in a
* custom event.
*
* @see #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating
* parameters.
*
* @code
* - (void)startLevel
{
NSDictionary *params =
[NSDictionary dictionaryWithObjectsAndKeys:@"100", // Parameter Value
@"Current Points", // Parameter Name
nil];
[Flurry logEvent:@"Level Played" withParameters:params timed:YES];
// Start user on level
}
- (void)endLevel
{
// User gained additional 100 points in Level
NSDictionary *params =
[NSDictionary dictionaryWithObjectsAndKeys:@"200", // Parameter Value
@"Current Points", // Parameter Name
nil];
[Flurry endTimedEvent:@"Level Played" withParameters:params];
// User done with level
}
* @endcode
*
* @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme
* that can be easily understood by non-technical people in your business domain.
* @param parameters A map containing Name-Value pairs of parameters.
* @param timed Specifies the event will be timed.
*/
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters timed:(BOOL)timed;
/*!
* @brief Ends a timed event specified by @c eventName and optionally updates parameters with @c parameters.
* @since 2.8.4
*
* This method ends an existing timed event. If parameters are provided, this will overwrite existing
* parameters with the same name or create new parameters if the name does not exist in the parameter
* map set by #logEvent:withParameters:timed:.
*
* @note You should not pass private or confidential information about your users in a
* custom event. \n
* If the app is backgrounded prior to ending a timed event, the Flurry SDK will automatically
* end the timer on the event. \n
* #endTimedEvent:withParameters: is ignored if called on a previously
* terminated event.
*
* @see #logEvent:withParameters:timed: for details on starting a timed event with parameters.
*
* @code
* - (void)startLevel
{
NSDictionary *params =
[NSDictionary dictionaryWithObjectsAndKeys:@"100", // Parameter Value
@"Current Points", // Parameter Name
nil];
[Flurry logEvent:@"Level Played" withParameters:params timed:YES];
// Start user on level
}
- (void)endLevel
{
// User gained additional 100 points in Level
NSDictionary *params =
[NSDictionary dictionaryWithObjectsAndKeys:@"200", // Parameter Value
@"Current Points", // Parameter Name
nil];
[Flurry endTimedEvent:@"Level Played" withParameters:params];
// User done with level
}
* @endcode
*
* @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme
* that can be easily understood by non-technical people in your business domain.
* @param parameters A map containing Name-Value pairs of parameters.
*/
+ (void)endTimedEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters; // non-nil parameters will update the parameters
//@}
/** @name Page View Methods
* Count page views.
*/
//@{
/*!
* @brief Automatically track page views on a @c UINavigationController or @c UITabBarController.
* @since 2.7
*
* This method increments the page view count for a session based on traversing a UINavigationController
* or UITabBarController. The page view count is only a counter for the number of transitions in your
* app. It does not associate a name with the page count. To associate a name with a count of occurences
* see #logEvent:.
*
* @note Please make sure you assign the Tab and Navigation controllers to the view controllers before
* passing them to this method.
*
* @see #logPageView for details on explictly incrementing page view count.
*
* @code
* -(void) trackViewsFromTabBar:(UITabBarController*) tabBar
{
[Flurry logAllPageViews:tabBar];
}
* @endcode
*
* @param target The navigation or tab bar controller.
*/
+ (void)logAllPageViews:(id)target;
/*!
* @brief Explicitly track a page view during a session.
* @since 2.7
*
* This method increments the page view count for a session when invoked. It does not associate a name
* with the page count. To associate a name with a count of occurences see #logEvent:.
*
* @see #logAllPageViews for details on automatically incrementing page view count based on user
* traversing navigation or tab bar controller.
*
* @code
* -(void) trackView
{
[Flurry logPageView];
}
* @endcode
*
*/
+ (void)logPageView;
//@}
/** @name User Info
* Methods to set user information.
*/
//@{
/*!
* @brief Assign a unique id for a user in your app.
* @since 2.7
*
* @note Please be sure not to use this method to pass any private or confidential information
* about the user.
*
* @param userID The app id for a user.
*/
+ (void)setUserID:(NSString *)userID;
/*!
* @brief Set your user's age in years.
* @since 2.7
*
* Use this method to capture the age of your user. Only use this method if you collect this
* information explictly from your user (i.e. - there is no need to set a default value).
*
* @note The age is aggregated across all users of your app and not available on a per user
* basis.
*
* @param age Reported age of user.
*
*/
+ (void)setAge:(int)age;
/*!
* @brief Set your user's gender.
* @since 2.7
*
* Use this method to capture the gender of your user. Only use this method if you collect this
* information explictly from your user (i.e. - there is no need to set a default value). Allowable
* values are @c @"M" or @c @"F"
*
* @note The gender is aggregated across all users of your app and not available on a per user
* basis.
*
* @param gender Reported gender of user.
*
*/
+ (void)setGender:(NSString *)gender; // user's gender m or f
//@}
/** @name Location Reporting
* Methods for setting location information.
*/
//@{
/*!
* @brief Set the location of the session.
* @since 2.7
*
* Use information from the CLLocationManager to specify the location of the session. Flurry does not
* automatically track this information or include the CLLocation framework.
*
* @note Only the last location entered is captured per session. \n
* Regardless of accuracy specified, the Flurry SDK will only report location at city level or higher. \n
* Location is aggregated across all users of your app and not available on a per user basis. \n
* This information should only be captured if it is germaine to the use of your app.
*
* @code
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
* @endcode
*
* After starting the location manager, you can set the location with Flurry. You can implement
* CLLocationManagerDelegate to be aware of when the location is updated. Below is an example
* of how to use this method, after you have recieved a location update from the locationManager.
*
* @code
CLLocation *location = locationManager.location;
[Flurry setLatitude:location.coordinate.latitude
longitude:location.coordinate.longitude
horizontalAccuracy:location.horizontalAccuracy
verticalAccuracy:location.verticalAccuracy];
* @endcode
* @param latitude The latitude.
* @param longitude The longitude.
* @param horizontalAccuracy The radius of uncertainty for the location in meters.
* @param verticalAccuracy The accuracy of the altitude value in meters.
*
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude horizontalAccuracy:(float)horizontalAccuracy verticalAccuracy:(float)verticalAccuracy;
//@}
/** @name Session Reporting Calls
* Optional methods that can be called at any point to control session reporting.
*/
//@{
/*!
* @brief Set session to report when app closes.
* @since 2.7
*
* Use this method report session data when the app is closed. The default value is @c YES.
*
* @note This method is rarely invoked in iOS >= 3.2 due to the updated iOS lifecycle.
*
* @see #setSessionReportsOnPauseEnabled:
*
* @param sendSessionReportsOnClose YES to send on close, NO to omit reporting on close.
*
*/
+ (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose;
/*!
* @brief Set session to report when app is sent to the background.
* @since 2.7
*
* Use this method report session data when the app is paused. The default value is @c YES.
*
* @param setSessionReportsOnPauseEnabled YES to send on pause, NO to omit reporting on pause.
*
*/
+ (void)setSessionReportsOnPauseEnabled:(BOOL)setSessionReportsOnPauseEnabled;
/*!
* @brief Enable custom event logging.
* @since 2.7
*
* Use this method to allow the capture of custom events. The default value is @c YES.
*
* @param value YES to enable event logging, NO to stop custom logging.
*
*/
+ (void)setEventLoggingEnabled:(BOOL)value;
/*!
* @brief Set device push token.
* @since 2.7
*
* After the device has successfully registered with APNS, call this method to set the push token received from APNS.
*
*
*/
+ (void)setPushToken:(NSString *)pushToken;
//@}
@end

View File

@ -1,324 +0,0 @@
//
// FlurryAdDelegate.h
// Flurry
//
// Copyright 2010 - 2012 Flurry, Inc. All rights reserved.
//
// Methods in this header file are for use with Flurry
//
#import <UIKit/UIKit.h>
typedef enum {
WEB_BANNER = 1,
WEB_TAKEOVER = 2,
VIDEO_TAKEOVER = 3,
AD_BANNER = 4,
AD_TAKEOVER = 5,
NETWORK_BANNER = 6,
NETWORK_TAKEOVER = 7
} FlurryAdType;
/*!
* @brief Provides all available delegates for receiving callbacks related to Ad Serving.
*
* Set of methods that allow developers to manage and take actions within
* different phases of App ad display.
*
* @note This class serves as a delegate for FlurryAds. \n
* For additional information on how to use Flurry's Ads SDK to
* attract high-quality users and monetize your user base see <a href="http://wiki.flurry.com/index.php?title=Publisher">Support Center - Publisher</a>.
* @author 2010 - 2012 Flurry, Inc. All Rights Reserved.
* @version 4.2.0
*
*/
@protocol FlurryAdDelegate <NSObject>
@optional
/*!
* @brief Invoked when an ad is received for the specified @c adSpace.
* @since 4.1
*
* This method informs the app that an ad has been received and is available for display.
*
* @see FlurryAds#fetchAdForSpace:frame:size: for details on the method that will invoke this delegate.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void) spaceDidReceiveAd:(NSString*)adSpace;
/*!
* @brief Invoked when an ad can not be retrieved for the specified @c adSpace.
* @since 4.1
*
* This method informs the app that an ad has failed to be received for the given adSpace.
*
* @see FlurryAds#fetchAdForSpace:frame:size: for details on the method that will invoke this delegate.
*
* @param adSpace The placement of an ad in your app, where placement may
* @param error The error, if known, that caused ads not to be received.
* be splash screen for SPLASH_AD.
*/
- (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error;
/*!
* @brief Invoked when an ad is about to display on the specified @c adSpace.
* @since 4.1.0
*
* This method informs the app that an ad is about to be displayed. You can decide at this point not to show this ad by simply returning NO.
*
* @see FlurryAds#displayAdForSpace:view: for details on the method that will invoke this delegate. \n
* FlurryAds#fetchAndDisplayAdForSpace:view:size: for details on the method that will invoke this delegate.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param interstitial YES/NO if the space to display will be an interstitial.
*/
- (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial;
/*!
* @brief [Deprecated] This method is deprecated. -[spaceShouldDisplay:interstitial:] should be used.
*/
- (BOOL)spaceShouldDisplay:(NSString*)adSpace forType:(FlurryAdType)type;
/*!
* @brief Invoked when an ad fails to render.
* @since 4.0.0
*
* This method informs the user an ad was retrieved, however, was unsuccessful in displaying to the user (could be lost network connectivity for example).
*
* @see FlurryAds#displayAdForSpace:view: for details on the method that will invoke this delegate. \n
* FlurryAds#fetchAndDisplayAdForSpace:view:size: for details on the method that will invoke this delegate.
*
* @param adSpace The placement of an ad in your app, where placement may
* @param error The error, if known, that caused ads not to be rendered.
* be splash screen for SPLASH_AD.
*/
- (void) spaceDidFailToRender:(NSString *)space error:(NSError *)error;
/*!
* @brief Invoked when the ad will be removed.
* @since 4.1
*
* This method informs the app that an ad will be removed.
*
* @param adSpace The placement of an ad in your app, where placement may be splash screen for SPLASH_AD.
* @param interstitial YES/NO indicates if space being removed is an interstitial
*
*/
- (void)spaceWillDismiss:(NSString *)adSpace interstitial:(BOOL)interstitial;
/*!
* @brief Invoked when the ad has been removed.
* @since 4.0.0
*
* This method informs the app that an ad has closed. You can use this to resume app
* states.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param interstitial YES/NO indicates if space being removed is an interstitial
*/
- (void)spaceDidDismiss:(NSString *)adSpace interstitial:(BOOL)interstitial;
/*!
* @brief Invoked when the ad has been selected that will take the user out of the app.
* @since 4.0.0
*
* This method informs the app that an ad has been clicked and the user is about to be taken outside the app.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void)spaceWillLeaveApplication:(NSString *)adSpace;
/*!
* @brief Invoked when a space will be expanded.
* @since 4.1
*
* This method informs the app an ad space (typcially a banner) will be expanded. Apps should pause their state when they receive this notification
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void) spaceWillExpand:(NSString *)adSpace;
/*!
* @brief Invoked when a space will be collapsed.
* @since 4.1
*
* This method informs the app an ad space (typcially a banner) will be collapsed.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void) spaceWillCollapse:(NSString *)adSpace;
/*!
* @brief Invoked when a space has been collapsed.
* @since 4.1
*
* This method informs the app an ad space (typcially a banner) has been collapsed. Apps should resume their state when they receive this notification
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void) spaceDidCollapse:(NSString *)adSpace;
/*!
* @brief Informational callback invoked when an ad is clicked for the specified @c adSpace.
* @since 4.1
*
* This method informs the app that an ad has been clicked. This should not be used to adjust state of an app. It is only intended for informational purposes.
*
* @param adSpace The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
- (void) spaceDidReceiveClick:(NSString*)adSpace;
/*!
* @brief Invoked when a video finishes playing
* @since 4.2.0
*
* This method informs the app that a video associated with an ad has finished playing
*
* @param adSpace The placement of an ad in your app, where placement may be splash screen for SPLASH_AD.
*
*/
- (void)videoDidFinish:(NSString *)adSpace;
@optional
#pragma mark App Keys
/** @name Third party network Calls
* Optional calls to pass information needed to display ads through 3rd parties.
*/
//@{
/*!
* @brief The Millennial APID.
* @since 4.0.0
*
* This is the id for your app as set in Millennial, found here: https://developer.millennialmedia.com/Application/index.php#manageApps.
*/
- (NSString *)appSpotMillennialAppKey; //your millennial APID, found here: https://developer.millennialmedia.com/Application/index.php#manageApps
/*!
* @brief The Millennial APID for interstitials.
* @since 4.0.0
*
* This is the id for your app as set in Millennial, found here: https://developer.millennialmedia.com/Application/index.php#manageApps.
*/
- (NSString *)appSpotMillennialInterstitalAppKey;
/*!
* @brief The InMobi APID.
* @since 4.0.0
*
* This is the id for your app as set in InMobi, found here: https://www.inmobi.com/pub/mysite.html?platFormType=all
*/
- (NSString *)appSpotInMobiAppKey;
/*!
* @brief The AdMob Publisher Id.
* @since 4.0.0
*
* This is the id for your app as set in AdMob, found here: http://www.admob.com/my_sites/ (click manage settings)
*/
- (NSString *)appSpotAdMobPublisherID;
/*!
* @brief The Mobclix Application Id.
* @since 4.0.0
*
* This is the id for your app as set in Mobclix
*/
- (NSString *)appSpotMobclixApplicationID;
/*!
* @brief The Jumptap Publisher Id.
* @since 4.1.2
*
* This is the pub id for your app as set in Jumptap
*/
- (NSString *)appSpotJumptapPublisherID;
/*!
* @brief The Jumptap Site Id.
* @since 4.1.2
*
* This is the site id for your app as set in Jumptap. It is an optional parameter.
*/
- (NSString *)appSpotJumptapSiteID;
/*!
* @brief Jumptap Banner Ad Spot ID
* @since 4.1.2
*
* This is the ad spot id for a Banner (320x50) ad spot set in JumpTap
*/
- (NSString *)appSpotJumptapBannerAdSpotID;
/*!
* @brief Jumptap Leaderboard Ad Spot ID
* @since 4.1.2
*
* This is the ad spot id for a Leaderboard (720x90) ad spot set in JumpTap
*/
- (NSString *)appSpotJumptapLeaderboardAdSpotID;
/*!
* @brief Jumptap Medium Rectange Ad Spot ID
* @since 4.1.2
*
* This is the ad spot id for a Medium Rectangle (320x50) ad spot set in JumpTap.
* The Medium Rectangle Ad Spot ID will be used whenever the ad frame can fit it
* (e.g. interstitial ads).
*/
- (NSString *)appSpotJumptapMediumRectangleAdSpotID;
/*!
* @brief The Greystripe Application Id.
* @since 4.0.0
*
* This is the id for your app as set in Greystripe
*/
- (NSString *)appSpotGreystripeApplicationID;
#pragma mark Information
#pragma mark Callbacks
/*!
* @brief [Deprecated] Allow you to set your rootViewController.
* @since 4.0.0
* @deprecated
*
* This method has been deprecated. Please call FlurryAds#initialze: instead.
*
*/
- (id)appSpotRootViewController;
#pragma mark Optional settings
/**
Some networks support accelerometer-enabled ads.
*/
/*!
* @brief For networks that support accelerometer-enabled ads.
* @since 4.0.0
*
* This method allows you to enable accelerometer based ads for networks that support this setting via the client sdk. Set to NO if your app uses the accelerometer
to avoid conflict. Set to YES if you want the special ads. Default is NO.
*/
- (BOOL)appSpotAccelerometerEnabled;
//@}
@end

View File

@ -1,464 +0,0 @@
//
// FlurryAds.h
// Flurry iOS Analytics Agent
//
// Copyright 2009-2012 Flurry, Inc. All rights reserved.
//
// Methods in this header file are for use by Flurry Publishers
#import <UIKit/UIKit.h>
typedef enum {
BANNER_TOP = 1,
BANNER_BOTTOM = 2,
FULLSCREEN = 3,
} FlurryAdSize;
@protocol FlurryCustomAdNetwork;
@protocol FlurryCustomAdNetworkProperties;
/*!
* @brief Provides all available methods for displaying ads.
*
* Set of methods that allow publishers to configure, target, and deliver ads to their customers.
*
* @note This class depends on Flurry.h.
* For information on how to use Flurry's Ads SDK to
* attract high-quality users and monetize your user base see <a href="http://support.flurry.com/index.php?title=Publishers">Support Center - Publishers</a>.
*
* @author 2009 - 2012 Flurry, Inc. All Rights Reserved.
* @version 4.2.0
*
*/
@interface FlurryAds : NSObject {
}
/*!
* @brief Retrieves an ad for the given @c space.
* @since 4.1.0
*
* This method will attempt to retrieve ads for the given space from the Flurry server.
*
* @note The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. For example, if you are displaying a full screen ad on your
* splash screen and after level completeion, you may have the following spaces
* @c @"SPLASH_AD" and @c @"LEVEL_AD".
*
* @see #removeAdFromSpace: for details on manually removing an ad from a view. \n
* FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received.
* FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request.
* #displayAdForSpace: for details on displaying an available ad.
*
* @code
* - (void)fetchAd:(NSString *)placement
{
// Placement may be SPLASH_AD as noted above
[FlurryAds fetchAdForSpace:placement view:self.view.frame size:FULLSCREEN];
}
// Show whenever delegate is invoked
- (void) spaceDidReceiveAd:(NSString *)adSpace {
// Received Ad
[FlurryAds displayAdForSpace:adSpace];
}
// Alternatively, try to display at a certain point in the app
- (void) levelComplete {
if([FlurryAds adReadyForSpace:adSpace]) {
[FlurryAds displayAdForSpace:adSpace];
}
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param frame The frame of the view that will be used for the ad container. Note: for fullscreen ads, this value is not used (you can pass in bounds of window).
* @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
*/
+(void) fetchAdForSpace:(NSString*)space frame:(CGRect)frame size:(FlurryAdSize)size;
/*!
* @brief Returns if an ad is currently ready to display for a given @c space.
* @since 4.1.0
*
* This method will verify if there is an ad is currently available for this
* user. If an ad is not available, you may call #fetchAdForSpace:view:size: to load a new ad.
*
* @note If this method returns YES, an ad will be available when you attempt to display an ad. However, it is still advisable to listen to the delegate FlurryAdsDelegate#spaceDidFailToRender:. \n
The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. For example, if you are displaying a full screen ad on your
* splash screen and after level completeion, you may have the following spaces
* @c @"SPLASH_AD" and @c @"LEVEL_AD".
*
* @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
#displayAdForSpace: for details on displaying the available ad.
*
* @code
* - (void)showButtonForAd:(NSString *)placement
{
// Placement may be SPLASH_AD as noted above
if([FlurryAds adReadyForSpace:placement])
{
// Show button that ads are available.
}
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*
* @return YES/NO to indicate if an ad is ready to be displayed.
*/
+(BOOL) adReadyForSpace:(NSString*)space;
/*!
* @brief Display an ad for the given @c space.
* @since 4.1.0
*
* This method will display an ad if one is ready for display on the device.
*
* @note The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
* splash screen and after level completeion, you may have the following spaces
* @c @"SPLASH_AD" and @c @"LEVEL_AD".
*
* @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
#adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
* #removeAdFromSpace: for details on manually removing an ad from a view. \n
* FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
* FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
*
* @code
* - (void)showFullscreenAd:(NSString *)placement
{
// Placement may be SPLASH_AD as noted above
if([FlurryAds adReadyForSpace:placement])
{
[FlurryAds displayAdForSpace:placement onView:view];
}
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* @param view The view to place the ad. The view frame should be identical to the view frame passed in #fetchAdForSpace:frame:size. Note view is not used for interstitials.
* be splash screen for SPLASH_AD.
*/
+ (void)displayAdForSpace:(NSString*)space onView:(UIView *)view;
/*!
* @brief Display an ad for the given interstitial @c space.
* @since 4.1.0
*
* This method will display an interstitial ad if one is ready for display on the device for specified UIViewController instance
*
* @note The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
* splash screen and after level completeion, you may have the following spaces
* @c @"SPLASH_AD" and @c @"LEVEL_AD".
*
* @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
#adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
* #removeAdFromSpace: for details on manually removing an ad from a view. \n
* FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
* FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
*
* @code
* in UIViewController based class:
* - (void)showFullscreenAd:(NSString *)placement
{
// Placement may be SPLASH_AD as noted above
if([FlurryAds adReadyForSpace:placement])
{
[FlurryAds displayAdForSpace:placement modallyForViewController:self];
}
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* @param viewController The viewController to show the fullscreen ad modally.
* Note this method should not be used for banners.
*/
+ (void)displayAdForSpace:(NSString*)space modallyForViewController:(UIViewController *)viewController;
/*!
* @brief [Deprecated] Check if an ad is available for the given @c space.
* @since 4.0.0
* @deprecated
*
* [Deprecated] This method will verify with the Flurry server if an ad is currently available for this
* user. If an ad is not available, we recommend not providing the user the
* option to view. For example, you may have a button that reads "See other great apps!".
* That button should only be displayed if this method returns YES.
*
* @note This method has been deprecated.
*
* @see #fetchAdForSpace:view:size: for replacement method.\n
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container.
* @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
* @param timeout The maximum amount of time to wait for the server to return a result. Set this to 0 to check the cache and return immediately.
*
* @return YES/NO to indicate if an ad is available.
*/
+(BOOL) isAdAvailableForSpace:(NSString*)space view:(UIView *)view size:(FlurryAdSize)size timeout:(int64_t)timeout;
/*!
* @brief [Deprecated] Display an ad for the given @c space.
* @since 4.0.0
* @deprecated
*
* [Deprecated] This method will display an ad if one is available from the Flurry server for this
* user.
*
* @note This method has been deprecated.
*
* @see #fetchAndDisplayAdForSpace:view:size:timeout: for replacement method
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container.
* @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
* @param timeout The maximum amount of time to wait for the server to return a valid ad. Set this to 0 to display an ad in the background (e.g. - for showing banners).
*
* @return YES/NO to indicate if an ad is available.
*/
+ (BOOL)showAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size timeout:(int64_t)timeout;
/*!
* @brief Fetch and Display an ad for the given @c space.
* @since 4.0.0
*
* This method will display an ad if one is available from the Flurry server for this
* user.
*
* @note If this method returns YES, an ad is available for the space within @c timeout. \n
* This is a blocking method that allows you to change the user experience based on availability of an ad. If you would like to display an ad asynchronously, just set timeout to 0. This is useful in the case of banners for instance where the user should not wait for its display. If you are loading async with timeout set to 0, ignore the return value of this method and rely exclusively on the relevant delegate methods listed below\n
* The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
* splash screen and after level completeion, you may have the following spaces
* @c @"SPLASH_AD" and @c @"LEVEL_AD".
*
* @see #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
* #removeAdFromSpace: for details on manually removing an ad from a view. \n
* FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received.
* FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request.
* FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
* FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
*
* @code
* - (void)showFullscreenAd:(NSString *)placement
{
// Placement may be SPLASH_AD as noted above
[FlurryAds fetchAndDisplayAdForSpace:placement view:self.view size:FULLSCREEN timeout:3000];
}
- (void)viewWillAppear:(BOOL)animated
{
// Show a banner whenever this view appears
// Display banner ad completely asyncrhonously by providing timeout == 0
[FlurryAds fetchAndDisplayAdForSpace:@"VIEW_XYZ_BANNER_AD" view:self.view size:BANNER_BOTTOM timeout:0];
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
* @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container.
* @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
*/
+ (void)fetchAndDisplayAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size;
/*!
* @brief Removes an ad for the given @c space.
* @since 4.0.0
*
* This method will remove an ad if one is currently displaying.
*
* @note The @c space simply represents the placement of the ad in your app and should be
* unique for each placement. Only one ad will show at a time for any given ad space.
*
* @see #isAdAvailableForSpace:view:size:timeout: for details on displaying an available ad. \n
* #removeAdFromSpace: for details on manually removing an ad from a view. \n
* FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
*
* @code
* - (void)viewDidUnload
{
// Remove a banner whenever this view dissapears
[FlurryAds removeAdFromSpace:@"VIEW_XYZ_BANNER_AD"];
}
* @endcode
*
* @param space The placement of an ad in your app, where placement may
* be splash screen for SPLASH_AD.
*/
+ (void) removeAdFromSpace:(NSString*)space;
/*!
* @brief Initializes the ad serving system.
* @since 4.0
*
* This method initializes the ad serving system and can be used to pre-cache ads from the server (this is done when ad spaces are configured on the server).
*
* @note This method must be called sometime after Flurry#startSession:.
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
[FlurryAds setAdDelegate:self];
[FlurryAds initialize:myWindow.rootViewController];
// ....
}
* @endcode
*
* @param rvc The primary root view controller of your app.
*
*/
+ (void) initialize: (UIViewController *)rvc;
/*!
* @brief Sets the object to receive various delegate methods.
* @since 4.0
*
* This method allows you to register an object that will receive
* notifications at different phases of ad serving.
*
* @see FlurryAdDelegate.h for details on delegates available.
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
[FlurryAds setAdDelegate:self];
// ....
}
* @endcode
*
* @param delegate The object to receive notifications of various ad actions.
*
*/
+ (void)setAdDelegate:(id)delegate;
/*!
* @brief Informs server to send test ads.
* @since 4.0
*
* This method allows you to request test ads from the server. These ads do not generate revenue so it is CRITICAL this call is removed prior to app submission.
*
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
[FlurryAds enableTestAds:YES];
// ....
}
* @endcode
*
* @param enable YES to receive test ads to the device. Not including this method is equivalent to passing NO.
*
*/
+ (void)enableTestAds:(BOOL)enable;
/*!
* @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when a user clicks on an ad.
* @since 4.0.0
*
* UserCookies allow the developer to specify information on a user executing an ad action. There is one UserCookie object, and on each ad click that UserCookie is transmitted to the Flurry servers. The UserCookie key/value pairs will be transmitted back to the developer via the app callback if one is set. This is useful for rewarded inventory, to identify which of your users should be rewarded when a reward callback is sent.
*
* @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set userCookies, you must call #clearUserCookies.
* @see #clearUserCookies for details on removing user cookies set through this method.
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
NSDictionary *cookies =
[NSDictionary dictionaryWithObjectsAndKeys:@"xyz123", // Parameter Value
@"UserCharacterId", // Parameter Name
nil];
[FlurryAds setUserCookies:cookies];
// ....
}
* @endcode
*
* @param userCookies The information about the user executing ad actions. Note: do not transmit personally identifiable information in the user cookies.
*/
+ (void) setUserCookies:(NSDictionary *) userCookies;
/*!
* @brief Removes a previously set dictionary of key/value pairs.
* @since 4.0.0
*
* This method removes information from the one UserCookie object.
*
* @see #setUserCookies: for details on setting user cookies.
*
*/
+ (void) clearUserCookies;
/*!
* @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when an ad is requested.
* @since 4.0.0
*
* Keywords allow the developer to specify information on a user executing an ad action for the purposes of targeting. There is one keywords object that is transmitted to the Flurry servers on each ad request. If corresponding keywords are matched on the ad server, a subset of targeted ads will be delivered. This allows partners to supply information they track internally, which is not available to Flurry's targeting system.
*
* @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set keywords, you must call #clearKeywords.
* @see #clearKeywords for details on removing keywords set through this method.
*
* @code
* - (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Optional Flurry startup methods
[Flurry startSession:@"YOUR_API_KEY"];
// Specify that user loves vacations
NSDictionary *keywords =
[NSDictionary dictionaryWithObjectsAndKeys:@"vacation", // Parameter Value
@"UserPreference", // Parameter Name
nil];
[FlurryAds setKeywords:keywords];
// ....
}
* @endcode
*
* @param keywords The information about the user to be used in targeting an ad. Note: do not transmit personally identifiable information in keywords.
*/
+ (void) setKeywordsForTargeting:(NSDictionary*) keywords;
/*!
* @brief Removes a previously set dictionary of key/value pairs.
* @since 4.0.0
*
* This method removes information from the one keywords object.
*
* @see #setKeywords: for details on setting keywords.
*
*/
+ (void) clearKeywords;
/*!
* @brief Method to add a custom ad network to be served through the standard Flurry ad system.
* @since 4.0.0
*
* This method adds a network with the necessary publisher supplied properties to the Flurry sdk.
*
* @see @c FlurryCustomAdNetwork and @c FlurryCustomAdNetworkProperties for details.
*
*/
+ (void) addCustomAdNetwork:(Class<FlurryCustomAdNetwork>)adNetworkClass withProperties:(id<FlurryCustomAdNetworkProperties>)adNetworkProperties;
@end

View File

@ -1 +0,0 @@
ad04773003101a8d05f3afb8fe384a2087bd476b

View File

@ -1,7 +0,0 @@
//
// Prefix header for all source files of the 'libPluginFlurry' target in the 'libPluginFlurry' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif

View File

@ -1,281 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A375168AFD41008C1C7B /* Foundation.framework */; };
FA73FC9117A11B84007E23C2 /* AdsFlurry.m in Sources */ = {isa = PBXBuildFile; fileRef = FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */; };
FA73FC9617A11E24007E23C2 /* libFlurryAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73FC9517A11E24007E23C2 /* libFlurryAds.a */; };
FAB6DFDD1756F22200C90D89 /* libFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB6DFDB1756F22200C90D89 /* libFlurry.a */; };
FAB6DFE01756F29800C90D89 /* AnalyticsFlurry.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
FA09A370168AFD41008C1C7B /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/${PRODUCT_NAME}";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
FA09A372168AFD41008C1C7B /* libPluginFlurry.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginFlurry.a; sourceTree = BUILT_PRODUCTS_DIR; };
FA09A375168AFD41008C1C7B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
FA73FC8E17A11B84007E23C2 /* AdsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsFlurry.h; sourceTree = "<group>"; };
FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdsFlurry.m; sourceTree = "<group>"; };
FA73FC9017A11B84007E23C2 /* PluginFlurry-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginFlurry-Prefix.pch"; sourceTree = "<group>"; };
FA73FC9317A11E24007E23C2 /* FlurryAdDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryAdDelegate.h; sourceTree = "<group>"; };
FA73FC9417A11E24007E23C2 /* FlurryAds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryAds.h; sourceTree = "<group>"; };
FA73FC9517A11E24007E23C2 /* libFlurryAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurryAds.a; sourceTree = "<group>"; };
FA86650E168BE22D0073E055 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
FAB6DFD81756F22200C90D89 /* Flurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flurry.h; sourceTree = "<group>"; };
FAB6DFDB1756F22200C90D89 /* libFlurry.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry.a; sourceTree = "<group>"; };
FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsFlurry.h; sourceTree = "<group>"; };
FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnalyticsFlurry.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FA09A36F168AFD41008C1C7B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */,
FAB6DFDD1756F22200C90D89 /* libFlurry.a in Frameworks */,
FA73FC9617A11E24007E23C2 /* libFlurryAds.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FA09A367168AFD41008C1C7B = {
isa = PBXGroup;
children = (
FA73FC8E17A11B84007E23C2 /* AdsFlurry.h */,
FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */,
FA73FC9017A11B84007E23C2 /* PluginFlurry-Prefix.pch */,
FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */,
FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */,
FAB6DFD81756F22200C90D89 /* Flurry.h */,
FAB6DFDB1756F22200C90D89 /* libFlurry.a */,
FA73FC9217A11E24007E23C2 /* FlurryAds */,
FA09A374168AFD41008C1C7B /* Frameworks */,
FA09A373168AFD41008C1C7B /* Products */,
);
sourceTree = "<group>";
};
FA09A373168AFD41008C1C7B /* Products */ = {
isa = PBXGroup;
children = (
FA09A372168AFD41008C1C7B /* libPluginFlurry.a */,
);
name = Products;
sourceTree = "<group>";
};
FA09A374168AFD41008C1C7B /* Frameworks */ = {
isa = PBXGroup;
children = (
FA86650E168BE22D0073E055 /* SystemConfiguration.framework */,
FA09A375168AFD41008C1C7B /* Foundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
FA73FC9217A11E24007E23C2 /* FlurryAds */ = {
isa = PBXGroup;
children = (
FA73FC9317A11E24007E23C2 /* FlurryAdDelegate.h */,
FA73FC9417A11E24007E23C2 /* FlurryAds.h */,
FA73FC9517A11E24007E23C2 /* libFlurryAds.a */,
);
path = FlurryAds;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FA09A371168AFD41008C1C7B /* PluginFlurry */ = {
isa = PBXNativeTarget;
buildConfigurationList = FA09A380168AFD41008C1C7B /* Build configuration list for PBXNativeTarget "PluginFlurry" */;
buildPhases = (
FA09A36E168AFD41008C1C7B /* Sources */,
FA09A36F168AFD41008C1C7B /* Frameworks */,
FA09A370168AFD41008C1C7B /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = PluginFlurry;
productName = libPluginFlurry;
productReference = FA09A372168AFD41008C1C7B /* libPluginFlurry.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FA09A369168AFD41008C1C7B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin;
};
buildConfigurationList = FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = FA09A367168AFD41008C1C7B;
productRefGroup = FA09A373168AFD41008C1C7B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FA09A371168AFD41008C1C7B /* PluginFlurry */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
FA09A36E168AFD41008C1C7B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FAB6DFE01756F29800C90D89 /* AnalyticsFlurry.m in Sources */,
FA73FC9117A11B84007E23C2 /* AdsFlurry.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
FA09A37E168AFD41008C1C7B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
SDKROOT = iphoneos;
};
name = Debug;
};
FA09A37F168AFD41008C1C7B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FA09A381168AFD41008C1C7B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginFlurry.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../platform/ios\"",
"\"$(SRCROOT)\"",
"\"$(SRCROOT)/FlurryAds\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = PluginFlurry;
SKIP_INSTALL = YES;
};
name = Debug;
};
FA09A382168AFD41008C1C7B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginFlurry.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../platform/ios\"",
"\"$(SRCROOT)\"",
"\"$(SRCROOT)/FlurryAds\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = PluginFlurry;
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FA09A37E168AFD41008C1C7B /* Debug */,
FA09A37F168AFD41008C1C7B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FA09A380168AFD41008C1C7B /* Build configuration list for PBXNativeTarget "PluginFlurry" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FA09A381168AFD41008C1C7B /* Debug */,
FA09A382168AFD41008C1C7B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FA09A369168AFD41008C1C7B /* Project object */;
}

View File

@ -1 +0,0 @@
9bd56193e2377b31e9254506f3ed39b4c185b4e9

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="sdk/NdComPlatform.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginNd91</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,9 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.libIAPAlipay"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>91SDK_LibProject_complete</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nd.commplatform.activity1" android:versionCode="1"
android:versionName="3.2.0"
android:installLocation="preferExternal">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:debuggable="true">
<activity android:name="com.nd.commplatform.activity.SNSControlCenterActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustPan" android:windowBackground="@null"
android:launchMode="singleTask"/>
<activity android:name="com.nd.commplatform.activity.SNSLoginActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustPan" android:screenOrientation="landscape"
android:windowBackground="@null"
android:launchMode="singleTask"/>
<activity android:name=".SNSAppPromotionActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:windowSoftInputMode="adjustPan"
android:theme="@android:style/Theme.NoTitleBar"
android:windowBackground="@null"/>
<service android:name="com.nd.commplatform.service.NdDownloadService"
android:process=":com.nd.commplatform.download"
android:enabled="true"
android:exported="false"/>
<receiver android:name="com.nd.commplatform.versionupdate.ND2VersionUpdateNotify"
android:process="android.intent.nd.sns.commplatform.versionupdate" android:exported="false"/>
<service android:name="com.nd.commplatform.versionupdate.ND2VersionUpdateService"
android:process="android.intent.nd.sns.commplatform.versionupdate" android:exported="false"/>
<service android:name="com.nd.commplatform.service.NdNewMessageNotification"
android:enabled="true"
android:exported="false"/>
</application>
<supports-screens android:anyDensity="true"
android:smallScreens="true" android:normalScreens="true"
android:largeScreens="true" />
</manifest>

View File

@ -1,12 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-16
android.library=true

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500"/>
</set>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0"
android:duration="500"/>
</set>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="500"/>
</set>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="500"/>
</set>

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<bitmap android:src="@drawable/nd3_background" android:tileMode="repeat"
xmlns:android="http://schemas.android.com/apk/res/android" />

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/nd3_button2" />
<item android:drawable="@drawable/nd3_button1" />
</selector>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/nd3_button_bg_dis02" />
<item android:state_pressed="true" android:drawable="@drawable/nd3_button_bg_02_press" />
<item android:drawable="@drawable/nd3_button_bg_02" />
</selector>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/nd3_button_long_press" />
<item android:drawable="@drawable/nd3_button_long" />
</selector>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/nd3_bnt_zhuxiao" />
<item android:state_enabled="false" android:drawable="@drawable/nd3_bnt_zhuxiao" />
<item android:drawable="@drawable/nd3_bnt_zhuxiao" />
</selector>

Some files were not shown because too many files have changed in this diff Show More