diff --git a/plugin/plugins/admob/include/AdsAdmob.h b/plugin/plugins/admob/include/AdsAdmob.h deleted file mode 100644 index 5f30c20d88..0000000000 --- a/plugin/plugins/admob/include/AdsAdmob.h +++ /dev/null @@ -1,96 +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. -****************************************************************************/ -#ifndef __CCX_ADS_ADMOB_H__ -#define __CCX_ADS_ADMOB_H__ - -#include "ProtocolAds.h" -#include -#include - -namespace cocos2d { namespace plugin { - -class AdsAdmob : public ProtocolAds -{ - PLUGIN_REGISTER_DECL(AdsAdmob) -public: - - typedef enum { - kSizeBanner = 0, - kSizeIABMRect, - kSizeIABBanner, - kSizeIABLeaderboard, - } AdmobBannerSize; - - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief config the application info - @param devInfo This parameter is the info of application, must contains: - AdmobID The publisher ID of admob. - @warning Must invoke this interface before other interfaces. - And invoked only once. - */ - virtual void configDeveloperInfo(TAdsDeveloperInfo devInfo); - - /** - @brief show adview - @param type The adview type need to show. - @param sizeEnum The size of the banner view. - (only used when type is kBannerAd) - Use the enum number in AdmobBannerSize. - @param pos The position where the adview be shown. - (only used when type is kBannerAd) - */ - virtual void showAds(AdsType type, int sizeEnum = 0, AdsPos pos = kPosCenter); - - /** - @brief Hide the adview - @param type The adview type need to hide. - */ - virtual void hideAds(AdsType type); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); - - /** - @brief Add the test device ID - @param deviceID The device ID - */ - void addTestDevice(const char* deviceID); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - virtual ~AdsAdmob(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_ADS_ADMOB_H__ */ diff --git a/plugin/plugins/admob/jsb_admob.ini b/plugin/plugins/admob/jsb_admob.ini deleted file mode 100644 index ab93d3da10..0000000000 --- a/plugin/plugins/admob/jsb_admob.ini +++ /dev/null @@ -1,60 +0,0 @@ -[admob] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_admob - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/admob/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/admob/include/AdsAdmob.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = AdsAdmob - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = AdsAdmob - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes - diff --git a/plugin/plugins/admob/platform/android/AdsAdmob.cpp b/plugin/plugins/admob/platform/android/AdsAdmob.cpp deleted file mode 100644 index 1cfba3f2b7..0000000000 --- a/plugin/plugins/admob/platform/android/AdsAdmob.cpp +++ /dev/null @@ -1,81 +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. -****************************************************************************/ -#include "AdsAdmob.h" -#include "PluginUtils.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(AdsAdmob) - -AdsAdmob::~AdsAdmob() -{ -} - -bool AdsAdmob::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.AdsAdmob"); -} - -void AdsAdmob::configDeveloperInfo(TAdsDeveloperInfo appInfo) -{ - ProtocolAds::configDeveloperInfo(appInfo); -} - -void AdsAdmob::showAds(AdsType type, int sizeEnum, AdsPos pos) -{ - ProtocolAds::showAds(type, sizeEnum, pos); -} - -void AdsAdmob::hideAds(AdsType type) -{ - ProtocolAds::hideAds(type); -} - -const char* AdsAdmob::getSDKVersion() -{ - return ProtocolAds::getSDKVersion(); -} - -void AdsAdmob::setDebugMode(bool debug) -{ - ProtocolAds::setDebugMode(debug); -} - -void AdsAdmob::addTestDevice(const char* deviceID) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "addTestDevice" - , "(Ljava/lang/String;)V")) - { - jstring strDeviceID = t.env->NewStringUTF(deviceID); - t.env->CallVoidMethod(pData->jobj, t.methodID, strDeviceID); - t.env->DeleteLocalRef(strDeviceID); - t.env->DeleteLocalRef(t.classID); - } -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/admob/proj.android/.project b/plugin/plugins/admob/proj.android/.project index a383057831..f512fd07f5 100644 --- a/plugin/plugins/admob/proj.android/.project +++ b/plugin/plugins/admob/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/admob/proj.android/build_native.sh b/plugin/plugins/admob/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/admob/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/admob/proj.android/jni/Android.mk b/plugin/plugins/admob/proj.android/jni/Android.mk deleted file mode 100644 index d9e6ef83db..0000000000 --- a/plugin/plugins/admob/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginAdmobStatic - -LOCAL_MODULE_FILENAME := libPluginAdmobStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - AdsAdmob.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/admob/proj.android/jni/Application.mk b/plugin/plugins/admob/proj.android/jni/Application.mk deleted file mode 100644 index 6c9133095b..0000000000 --- a/plugin/plugins/admob/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginAdmobStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java index 5395002616..7d85eece30 100644 --- a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java +++ b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java @@ -28,8 +28,6 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Set; -import org.cocos2dx.plugin.InterfaceAds.AdsAdapter; - import com.google.ads.*; import com.google.ads.AdRequest.ErrorCode; @@ -38,7 +36,7 @@ import android.content.Context; import android.util.Log; import android.view.WindowManager; -public class AdsAdmob implements AdsAdapter { +public class AdsAdmob implements InterfaceAds { private static final String LOG_TAG = "AdsAdmob"; private static Activity mContext = null; @@ -94,10 +92,10 @@ public class AdsAdmob implements AdsAdapter { @Override public void showAds(int adsType, int sizeEnum, int pos) { switch (adsType) { - case InterfaceAds.ADS_TYPE_BANNER: + case AdsWrapper.ADS_TYPE_BANNER: showBannerAd(sizeEnum, pos); break; - case InterfaceAds.ADS_TYPE_FULL_SCREEN: + case AdsWrapper.ADS_TYPE_FULL_SCREEN: LogD("Now not support full screen view in Admob"); break; default: @@ -113,10 +111,10 @@ public class AdsAdmob implements AdsAdapter { @Override public void hideAds(int adsType) { switch (adsType) { - case InterfaceAds.ADS_TYPE_BANNER: + case AdsWrapper.ADS_TYPE_BANNER: hideBannerAd(); break; - case InterfaceAds.ADS_TYPE_FULL_SCREEN: + case AdsWrapper.ADS_TYPE_FULL_SCREEN: break; default: break; @@ -178,7 +176,7 @@ public class AdsAdmob implements AdsAdapter { if (null == mWm) { mWm = (WindowManager) mContext.getSystemService("window"); } - InterfaceAds.addAdView(mWm, adView, curPos); + AdsWrapper.addAdView(mWm, adView, curPos); } }); } @@ -211,20 +209,20 @@ public class AdsAdmob implements AdsAdapter { @Override public void onDismissScreen(Ad arg0) { LogD("onDismissScreen invoked"); - InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!"); + AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!"); } @Override public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) { - int errorNo = InterfaceAds.RESULT_CODE_UnknownError; + int errorNo = AdsWrapper.RESULT_CODE_UnknownError; String errorMsg = "Unknow error"; switch (arg1) { case NETWORK_ERROR: - errorNo = InterfaceAds.RESULT_CODE_NetworkError; + errorNo = AdsWrapper.RESULT_CODE_NetworkError; errorMsg = "Network error"; break; case INVALID_REQUEST: - errorNo = InterfaceAds.RESULT_CODE_NetworkError; + errorNo = AdsWrapper.RESULT_CODE_NetworkError; errorMsg = "The ad request is invalid"; break; case NO_FILL: @@ -234,7 +232,7 @@ public class AdsAdmob implements AdsAdapter { break; } LogD("failed to receive ad : " + errorNo + " , " + errorMsg); - InterfaceAds.onAdsResult(mAdapter, errorNo, errorMsg); + AdsWrapper.onAdsResult(mAdapter, errorNo, errorMsg); } @Override @@ -245,13 +243,18 @@ public class AdsAdmob implements AdsAdapter { @Override public void onPresentScreen(Ad arg0) { LogD("onPresentScreen invoked"); - InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!"); + AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!"); } @Override public void onReceiveAd(Ad arg0) { LogD("onReceiveAd invoked"); - InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_AdsReceived, "Ads request received success!"); + AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsReceived, "Ads request received success!"); } } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/alipay/include/IAPAlipay.h b/plugin/plugins/alipay/include/IAPAlipay.h deleted file mode 100644 index 0085e19ab3..0000000000 --- a/plugin/plugins/alipay/include/IAPAlipay.h +++ /dev/null @@ -1,81 +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. -****************************************************************************/ -#ifndef __CCX_IAP_ALIPAY_H__ -#define __CCX_IAP_ALIPAY_H__ - -#include "ProtocolIAP.h" -#include -#include - -namespace cocos2d { namespace plugin { - -class IAPAlipay : public ProtocolIAP -{ - PLUGIN_REGISTER_DECL(IAPAlipay) -public: - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief config the developer info - @param devInfo This parameter is the info of developer, must contains key: - AlipayPartner The partner id of alipay account - AlipaySeller The seller id of alipay account - AlipayRsaPrivate The RSA private key of alipay account - AlipayPublic The public key of alipay account - AlipayNotifyUrl The notify url of developer (must not be empty) - AlipayPluginName The apk file name of Alipay (must not be empty) - @warning Must invoke this interface before other interfaces. - And invoked only once. - */ - virtual void configDeveloperInfo(TIAPDeveloperInfo devInfo); - - /** - @brief pay for product - @param info The info of product, must contains key: - productName The name of product - productPrice The price of product(must can be parse to float) - productDesc The description of product - @warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. - */ - virtual void payForProduct(TProductInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - virtual ~IAPAlipay(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_IAP_ALIPAY_H__ */ diff --git a/plugin/plugins/alipay/jsb_alipay.ini b/plugin/plugins/alipay/jsb_alipay.ini deleted file mode 100644 index 5265191fce..0000000000 --- a/plugin/plugins/alipay/jsb_alipay.ini +++ /dev/null @@ -1,60 +0,0 @@ -[alipay] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_alipay - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/alipay/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/alipay/include/IAPAlipay.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = IAPAlipay - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = IAPAlipay - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes - diff --git a/plugin/plugins/alipay/platform/android/IAPAlipay.cpp b/plugin/plugins/alipay/platform/android/IAPAlipay.cpp deleted file mode 100644 index 21657963e6..0000000000 --- a/plugin/plugins/alipay/platform/android/IAPAlipay.cpp +++ /dev/null @@ -1,84 +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. -****************************************************************************/ -#include "IAPAlipay.h" -#include "PluginUtils.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(IAPAlipay) - -IAPAlipay::~IAPAlipay() -{ -} - -/** -@brief plugin initialization -*/ -bool IAPAlipay::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.IAPAlipay"); -} - -/** -@brief config the developer info -@param devInfo This parameter is the info of developer, must contains key: - AlipayPartner The partner id of alipay account - AlipaySeller The seller id of alipay account - AlipayRsaPrivate The RSA private key of alipay account - AlipayPublic The public key of alipay account - AlipayNotifyUrl The notify url of developer (must not be empty) - AlipayPluginName The apk file name of Alipay (must not be empty) -@warning Must invoke this interface before other interfaces. - And invoked only once. -*/ -void IAPAlipay::configDeveloperInfo(TIAPDeveloperInfo devInfo) -{ - ProtocolIAP::configDeveloperInfo(devInfo); -} - -/** -@brief pay for product -@param info The info of product, must contains key: - productName The name of product - productPrice The price of product(must can be parse to float) - productDesc The description of product -@warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. -*/ -void IAPAlipay::payForProduct(TProductInfo info) -{ - ProtocolIAP::payForProduct(info); -} - -const char* IAPAlipay::getSDKVersion() -{ - return ProtocolIAP::getSDKVersion(); -} - -void IAPAlipay::setDebugMode(bool debug) -{ - ProtocolIAP::setDebugMode(debug); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/alipay/proj.android/.project b/plugin/plugins/alipay/proj.android/.project index c7bf0cc435..93e01793c8 100644 --- a/plugin/plugins/alipay/proj.android/.project +++ b/plugin/plugins/alipay/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/alipay/proj.android/build_native.sh b/plugin/plugins/alipay/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/alipay/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/alipay/proj.android/jni/Android.mk b/plugin/plugins/alipay/proj.android/jni/Android.mk deleted file mode 100644 index 20c61b7bc8..0000000000 --- a/plugin/plugins/alipay/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginAlipayStatic - -LOCAL_MODULE_FILENAME := libPluginAlipayStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - IAPAlipay.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/alipay/proj.android/jni/Application.mk b/plugin/plugins/alipay/proj.android/jni/Application.mk deleted file mode 100644 index bc7141a7ec..0000000000 --- a/plugin/plugins/alipay/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginAlipayStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/IAPAlipay.java b/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/IAPAlipay.java index 4d0dcade3d..3c799b7d03 100644 --- a/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/IAPAlipay.java +++ b/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/IAPAlipay.java @@ -28,8 +28,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Hashtable; -import org.cocos2dx.plugin.InterfaceIAP.IAPAdapter; - import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; @@ -41,7 +39,7 @@ import android.os.Message; import android.util.Log; import android.view.KeyEvent; -public class IAPAlipay implements IAPAdapter { +public class IAPAlipay implements InterfaceIAP { private static final String LOG_TAG = "IAPAlipay"; private static Activity mContext = null; @@ -97,7 +95,7 @@ public class IAPAlipay implements IAPAdapter { public void payForProduct(Hashtable info) { LogD("payForProduct invoked " + info.toString()); if (! networkReachable()) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "网络不可用"); + payResult(IAPWrapper.PAYRESULT_FAIL, "网络不可用"); return; } @@ -108,7 +106,7 @@ public class IAPAlipay implements IAPAdapter { MobileSecurePayHelper mspHelper = new MobileSecurePayHelper(mContext); boolean bInstalled = mspHelper.detectMobile_sp(); if (! bInstalled) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "未安装支付宝插件"); + payResult(IAPWrapper.PAYRESULT_FAIL, "未安装支付宝插件"); return; } @@ -138,12 +136,12 @@ public class IAPAlipay implements IAPAdapter { closeProgress(); mProgress = BaseHelper.showProgress(mContext, null, "正在支付", false, true); } else { - payResult(InterfaceIAP.PAYRESULT_FAIL, "支付失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); return; } } catch (Exception ex) { LogE("Remote call failed", ex); - payResult(InterfaceIAP.PAYRESULT_FAIL, "remote call failed"); + payResult(IAPWrapper.PAYRESULT_FAIL, "remote call failed"); return; } } @@ -200,21 +198,21 @@ public class IAPAlipay implements IAPAdapter { int retVal = resultChecker.checkSign(); // 返回验签结果以及交易状态 if (retVal == ResultChecker.RESULT_CHECK_SIGN_FAILED) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "签名验证失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "签名验证失败"); } else if (retVal == ResultChecker.RESULT_CHECK_SIGN_SUCCEED && resultChecker.isPayOk()) { - payResult(InterfaceIAP.PAYRESULT_SUCCESS, "支付成功"); + payResult(IAPWrapper.PAYRESULT_SUCCESS, "支付成功"); } else { - payResult(InterfaceIAP.PAYRESULT_FAIL, "支付失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); } } catch (Exception e) { e.printStackTrace(); - payResult(InterfaceIAP.PAYRESULT_FAIL, "结果解析失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "结果解析失败"); } } break; default: mAdapter.closeProgress(); - payResult(InterfaceIAP.PAYRESULT_FAIL, "支付失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); break; } @@ -335,7 +333,12 @@ public class IAPAlipay implements IAPAdapter { } private static void payResult(int ret, String msg) { - InterfaceIAP.onPayResult(mAdapter, ret, msg); + IAPWrapper.onPayResult(mAdapter, ret, msg); LogD("Alipay result : " + ret + " msg : " + msg); } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/flurry/include/AnalyticsFlurry.h b/plugin/plugins/flurry/include/AnalyticsFlurry.h deleted file mode 100644 index 6eb932e08d..0000000000 --- a/plugin/plugins/flurry/include/AnalyticsFlurry.h +++ /dev/null @@ -1,170 +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. -****************************************************************************/ -#ifndef __CCX_ANALYTICS_FLURRY_H__ -#define __CCX_ANALYTICS_FLURRY_H__ - -#include "ProtocolAnalytics.h" - -namespace cocos2d { namespace plugin { - -class AnalyticsFlurry : public ProtocolAnalytics -{ - PLUGIN_REGISTER_DECL(AnalyticsFlurry) -public: - enum Gender{ - FEMALE = 0, - MALE = 1 - }; - - virtual ~AnalyticsFlurry(); - - /** - @par override interface of base class - */ - - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief Start a new session. - @param appKey The identity of the application. - */ - virtual void startSession(const char* appKey); - - /** - @brief Stop a session. - @warning This interface only worked on android - */ - virtual void stopSession(); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - @note It must be invoked before calling startSession. - */ - virtual void setDebugMode(bool debug); - - /** - @brief Set the timeout for expiring a session. - @param millis In milliseconds as the unit of time. - @note It must be invoked before calling startSession. - */ - virtual void setSessionContinueMillis(long millis); - - /** - @brief log an error - @param errorId The identity of error - @param message Extern message for the error - */ - virtual void logError(const char* errorId, const char* message); - - /** - @brief log an event. - @param eventId The identity of event - @param paramMap Extern parameters of the event, use NULL if not needed. - */ - virtual void logEvent(const char* eventId, LogEventParamMap* paramMap = NULL); - - /** - @brief Track an event begin. - @param eventId The identity of event - */ - virtual void logTimedEventBegin(const char* eventId); - - /** - @brief Track an event end. - @param eventId The identity of event - */ - virtual void logTimedEventEnd(const char* eventId); - - /** - @brief Whether to catch uncaught exceptions to server. - @warning This interface only worked on android. - */ - virtual void setCaptureUncaughtException(bool enabled); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - /** - @par Unique interface of Flurry - */ - /** - @brief Sets the age of the user at the time of this session. - */ - void setAge(int age); - - /** - @brief Sets the gender of the user. - */ - void setGender(Gender gender); - - /** - @brief Sets the userId for this session. - */ - void setUserId(const char* userId); - - /** - @brief Log a page view. - */ - void logPageView(); - - /** - @brief Set the version name of the app. - @note It must be invoked before calling startSession. - */ - void setVersionName(const char* versionName); - - /** - @par interface for android - */ - /** - @brief Enable the use of HTTPS communications. - @warning This interface only worked on android - */ - void setUseHttps(bool useHttps); - - /** @brief Enable or disable detailed location reporting. - * @note It must be invoked before calling startSession. - * @warning This interface only worked on android - */ - void setReportLocation(bool enabled); - - /** - @par interface for ios - */ - /** - @brief Log a timed event with parameters. - @warning The paramMap is only worked on ios. - On android, paramMap is ignored. - */ - void logTimedEventBegin(const char* eventId, LogEventParamMap* paramMap); - void logTimedEventEnd(const char* eventId, LogEventParamMap* paramMap); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_ANALYTICS_FLURRY_H__ */ diff --git a/plugin/plugins/flurry/jsb_flurry.ini b/plugin/plugins/flurry/jsb_flurry.ini deleted file mode 100644 index 151a4ddbbf..0000000000 --- a/plugin/plugins/flurry/jsb_flurry.ini +++ /dev/null @@ -1,59 +0,0 @@ -[flurry] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_flurry - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/flurry/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/flurry/include/AnalyticsFlurry.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = AnalyticsFlurry - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = AnalyticsFlurry - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes diff --git a/plugin/plugins/flurry/platform/android/AnalyticsFlurry.cpp b/plugin/plugins/flurry/platform/android/AnalyticsFlurry.cpp deleted file mode 100644 index e6ce0752e8..0000000000 --- a/plugin/plugins/flurry/platform/android/AnalyticsFlurry.cpp +++ /dev/null @@ -1,246 +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. -****************************************************************************/ -#include "AnalyticsFlurry.h" -#include "PluginJniHelper.h" -#include -#include "PluginUtils.h" -#include "PluginJavaData.h" - -#if 1 -#define LOG_TAG "AnalyticsFlurry" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(AnalyticsFlurry) - -AnalyticsFlurry::~AnalyticsFlurry() -{ - LOGD("AnalyticsFlurry destructor"); -} - -bool AnalyticsFlurry::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.AnalyticsFlurry"); -} - -void AnalyticsFlurry::setReportLocation(bool enabled) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setReportLocation" - , "(Z)V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, enabled); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::logPageView() -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logPageView" - , "()V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::setVersionName(const char* versionName) -{ - return_if_fails(versionName != NULL && strlen(versionName) > 0); - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setVersionName" - , "(Ljava/lang/String;)V")) - { - jstring jversionName = t.env->NewStringUTF(versionName); - t.env->CallVoidMethod(pData->jobj, t.methodID, jversionName); - t.env->DeleteLocalRef(jversionName); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::setAge(int age) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setAge" - , "(I)V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, age); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::setGender(Gender gender) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setGender" - , "(B)V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, (jbyte)gender); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::setUserId(const char* userId) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - return_if_fails(userId != NULL && strlen(userId) > 0); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setUserId" - , "(Ljava/lang/String;)V")) - { - jstring juserId = t.env->NewStringUTF(userId); - t.env->CallVoidMethod(pData->jobj, t.methodID, juserId); - t.env->DeleteLocalRef(juserId); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::setUseHttps(bool useHttps) -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setUseHttps" - , "(Z)V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, useHttps); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsFlurry::logTimedEventBegin(const char* eventId) -{ - ProtocolAnalytics::logTimedEventBegin(eventId); -} - -void AnalyticsFlurry::logTimedEventBegin(const char* eventId, LogEventParamMap* paramMap) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - - if (paramMap == NULL) - { - ProtocolAnalytics::logTimedEventBegin(eventId); - } - else - { - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logTimedEventBegin" - , "(Ljava/lang/String;Ljava/util/Hashtable;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jobject jparamMap= PluginUtils::createJavaMapObject(t, paramMap); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jparamMap); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jparamMap); - t.env->DeleteLocalRef(t.classID); - } - } -} - -/** override methods of base class */ -/** Start a new session. */ -void AnalyticsFlurry::startSession(const char* appKey) -{ - ProtocolAnalytics::startSession(appKey); -} - -/** Stop a session. */ -void AnalyticsFlurry::stopSession() -{ - ProtocolAnalytics::stopSession(); -} - -/** Set the timeout for expiring a session. */ -void AnalyticsFlurry::setSessionContinueMillis(long millis) -{ - ProtocolAnalytics::setSessionContinueMillis(millis); -} - -/** Whether to catch uncaught exceptions to server.*/ -void AnalyticsFlurry::setCaptureUncaughtException(bool enabled) -{ - ProtocolAnalytics::setCaptureUncaughtException(enabled); -} - -const char* AnalyticsFlurry::getSDKVersion() -{ - return ProtocolAnalytics::getSDKVersion(); -} - -/** Set whether needs to output logs to console.*/ -void AnalyticsFlurry::setDebugMode(bool debug) -{ - ProtocolAnalytics::setDebugMode(debug); -} - -/** log an error */ -void AnalyticsFlurry::logError(const char* errorId, const char* message) -{ - ProtocolAnalytics::logError(errorId, message); -} - -/** log an event. */ -void AnalyticsFlurry::logEvent(const char* eventId, LogEventParamMap* paramMap) -{ - ProtocolAnalytics::logEvent(eventId, paramMap); -} - -/** end a timed event */ -void AnalyticsFlurry::logTimedEventEnd(const char* eventId) -{ - ProtocolAnalytics::logTimedEventEnd(eventId); -} - -void AnalyticsFlurry::logTimedEventEnd(const char* eventId, LogEventParamMap* paramMap) -{ - ProtocolAnalytics::logTimedEventEnd(eventId); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/flurry/platform/ios/AnalyticsFlurry.mm b/plugin/plugins/flurry/platform/ios/AnalyticsFlurry.mm deleted file mode 100644 index b9fbdf7ad8..0000000000 --- a/plugin/plugins/flurry/platform/ios/AnalyticsFlurry.mm +++ /dev/null @@ -1,221 +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. -****************************************************************************/ -#include "AnalyticsFlurry.h" -#include "Flurry.h" -#include "PluginUtilsIOS.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(AnalyticsFlurry) - -#define LOG_MAX_LENGTH (16 * 1024) - -static bool s_bDebugable = false; -void FlurryLogD(const char * pszFormat, ...) -{ - if (s_bDebugable) { - printf("AnalyticsFlurry : "); - char szBuf[LOG_MAX_LENGTH]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf(szBuf, LOG_MAX_LENGTH, pszFormat, ap); - va_end(ap); - printf("%s", szBuf); - printf("\n"); - } -} - -AnalyticsFlurry::~AnalyticsFlurry() -{ -} - -bool AnalyticsFlurry::init() -{ - return PluginUtilsIOS::initOCPlugin(this, "FlurryWrapper"); -} - -/** override methods of base class */ -/** Start a new session. */ -void AnalyticsFlurry::startSession(const char* appKey) -{ - ProtocolAnalytics::startSession(appKey); -} - -/** Stop a session. - only worked on android -*/ -void AnalyticsFlurry::stopSession() -{ - ProtocolAnalytics::stopSession(); -} - -/** Set whether needs to output logs to console.*/ -void AnalyticsFlurry::setDebugMode(bool debug) -{ - s_bDebugable = debug; - ProtocolAnalytics::setDebugMode(debug); -} - -/** Set the timeout for expiring a session. */ -void AnalyticsFlurry::setSessionContinueMillis(long millis) -{ - ProtocolAnalytics::setSessionContinueMillis(millis); -} - -/** log an error */ -void AnalyticsFlurry::logError(const char* errorId, const char* message) -{ - ProtocolAnalytics::logError(errorId, message); -} - -/** log an event. */ -void AnalyticsFlurry::logEvent(const char* eventId, LogEventParamMap* paramMap) -{ - ProtocolAnalytics::logEvent(eventId, paramMap); -} - -void AnalyticsFlurry::logTimedEventBegin(const char* eventId) -{ - ProtocolAnalytics::logTimedEventBegin(eventId); -} - -/** end a timed event */ -void AnalyticsFlurry::logTimedEventEnd(const char* eventId) -{ - ProtocolAnalytics::logTimedEventEnd(eventId); -} - -/** Whether to catch uncaught exceptions to server. - only worked on android - */ -void AnalyticsFlurry::setCaptureUncaughtException(bool enabled) -{ - ProtocolAnalytics::setCaptureUncaughtException(enabled); -} - -const char* AnalyticsFlurry::getSDKVersion() -{ - return ProtocolAnalytics::getSDKVersion(); -} - -void AnalyticsFlurry::setAge(int age) -{ - NSNumber* numAge = [NSNumber numberWithInt:age]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setAge:", numAge); -} - -void AnalyticsFlurry::setGender(Gender gender) -{ - NSString* ret = @"m"; - if (gender == FEMALE) { - ret = @"f"; - } - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setGender:", ret); -} - -void AnalyticsFlurry::setUserId(const char* userId) -{ - if (NULL == userId || strlen(userId) == 0) { - FlurryLogD("userId is invalid"); - return; - } - NSString* pUserID = [NSString stringWithUTF8String:userId]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setUserId:", pUserID); -} - -void AnalyticsFlurry::logPageView() -{ - PluginUtilsIOS::callOCFunctionWithName(this, "logPageView"); -} - -void AnalyticsFlurry::setVersionName(const char* versionName) -{ - NSString* pVer = [NSString stringWithUTF8String:versionName]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setVersionName:", pVer); -} - -/** - @warning only worked on android - */ -void AnalyticsFlurry::setUseHttps(bool useHttps) -{ - FlurryLogD("setUseHttps in flurry not available on iOS"); -} - -/** - @warning only worked on android - */ -void AnalyticsFlurry::setReportLocation(bool enabled) -{ - FlurryLogD("setReportLocation in flurry not available on iOS"); -} - -void AnalyticsFlurry::logTimedEventBegin(const char* eventId, LogEventParamMap* paramMap) -{ - if (NULL == eventId || strlen(eventId) == 0) { - FlurryLogD("eventId is invalid!"); - return; - } - - NSString* pId = [NSString stringWithUTF8String:eventId]; - if (NULL == paramMap) { - this->logTimedEventBegin(eventId); - } else { - NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logTimedEventBegin:withParam:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:pId withObject:dict]; - } - } - } -} - -void AnalyticsFlurry::logTimedEventEnd(const char* eventId, LogEventParamMap* paramMap) -{ - if (NULL == eventId || strlen(eventId) == 0) { - FlurryLogD("eventId is invalid!"); - return; - } - - NSString* pId = [NSString stringWithUTF8String:eventId]; - if (NULL == paramMap) { - this->logTimedEventEnd(eventId); - } else { - NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logTimedEventEnd:withParam:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:pId withObject:dict]; - } - } - } -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/flurry/platform/ios/FlurryWrapper.m b/plugin/plugins/flurry/platform/ios/FlurryWrapper.m deleted file mode 100644 index 14ba8bda1b..0000000000 --- a/plugin/plugins/flurry/platform/ios/FlurryWrapper.m +++ /dev/null @@ -1,129 +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 "FlurryWrapper.h" -#import "Flurry.h" - -@implementation FlurryWrapper - -- (void) startSession: (NSString*) appKey -{ - [Flurry startSession:appKey]; -} - -- (void) stopSession -{ - NSLog(@"stopSession in flurry not available on iOS"); -} - -- (void) setSessionContinueMillis: (NSNumber*) millis -{ - long lMillis = [millis longValue]; - int seconds = (int)(lMillis / 1000); - [Flurry setSessionContinueSeconds:seconds]; -} - -- (void) setCaptureUncaughtException: (NSNumber*) isEnabled -{ - NSLog(@"setCaptureUncaughtException in flurry not available on iOS"); -} - -- (void) setDebugMode: (NSNumber*) isDebugMode -{ - BOOL bDebug = [isDebugMode boolValue]; - [Flurry setDebugLogEnabled:bDebug]; -} - -- (void) logError: (NSString*) errorId withMsg:(NSString*) message -{ - NSString* msg = nil; - if (nil == message) { - msg = @""; - } else { - msg = message; - } - [Flurry logError:errorId message:msg exception:nil]; -} - -- (void) logEvent: (NSString*) eventId -{ - [Flurry logEvent:eventId]; -} - -- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap -{ - [Flurry logEvent:eventId withParameters:paramMap]; -} - -- (void) logTimedEventBegin: (NSString*) eventId -{ - [Flurry logEvent:eventId timed:YES]; -} - -- (void) logTimedEventEnd: (NSString*) eventId -{ - [Flurry endTimedEvent:eventId withParameters:nil]; -} - -- (NSString*) getSDKVersion -{ - return [Flurry getFlurryAgentVersion]; -} - -- (void) setAge: (NSNumber*) age -{ - int nAge = [age integerValue]; - [Flurry setAge:nAge]; -} - -- (void) setGender: (NSString*) gender -{ - [Flurry setGender:gender]; -} - -- (void) setUserId: (NSString*) userId -{ - [Flurry setUserID:userId]; -} - -- (void) logPageView -{ - [Flurry logPageView]; -} - -- (void) setVersionName: (NSString*) versionName -{ - [Flurry setAppVersion:versionName]; -} - -- (void) logTimedEventBegin: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap -{ - [Flurry logEvent:eventId withParameters:paramMap timed:YES]; -} - -- (void) logTimedEventEnd: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap -{ - [Flurry endTimedEvent:eventId withParameters:paramMap]; -} - -@end diff --git a/plugin/plugins/flurry/proj.android/.project b/plugin/plugins/flurry/proj.android/.project index 2c418957e0..49c5fb84c4 100644 --- a/plugin/plugins/flurry/proj.android/.project +++ b/plugin/plugins/flurry/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/flurry/proj.android/build_native.sh b/plugin/plugins/flurry/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/flurry/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/flurry/proj.android/jni/Android.mk b/plugin/plugins/flurry/proj.android/jni/Android.mk deleted file mode 100644 index a429de049f..0000000000 --- a/plugin/plugins/flurry/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginFlurryStatic - -LOCAL_MODULE_FILENAME := libPluginFlurryStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - AnalyticsFlurry.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/flurry/proj.android/jni/Application.mk b/plugin/plugins/flurry/proj.android/jni/Application.mk deleted file mode 100644 index 76dbd7b433..0000000000 --- a/plugin/plugins/flurry/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginFlurryStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AnalyticsFlurry.java b/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AnalyticsFlurry.java index f738728077..851dc32cc9 100644 --- a/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AnalyticsFlurry.java +++ b/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AnalyticsFlurry.java @@ -24,6 +24,9 @@ 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; @@ -32,170 +35,191 @@ 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 Context mContext = null; + protected static String TAG = "AnalyticsFlurry"; - private static boolean isDebug = false; - protected static void LogD(String msg) { - if (isDebug) { - Log.d(TAG, msg); - } - } + protected static void LogE(String msg, Exception e) { + Log.e(TAG, msg, e); + e.printStackTrace(); + } - public AnalyticsFlurry(Context context) { - mContext = context; - } - - @Override - public void startSession(String appKey) { - LogD("startSession invoked!"); - FlurryAgent.onStartSession(mContext, appKey); - } + private static boolean isDebug = false; + protected static void LogD(String msg) { + if (isDebug) { + Log.d(TAG, msg); + } + } - @Override - public void stopSession() { - LogD("stopSession invoked!"); - FlurryAgent.onEndSession(mContext); - } + public AnalyticsFlurry(Context context) { + mContext = context; + } + + @Override + public void startSession(String appKey) { + LogD("startSession invoked!"); + FlurryAgent.onStartSession(mContext, appKey); + } - @Override - public void setSessionContinueMillis(int millis) { - LogD("setSessionContinueMillis invoked!"); - FlurryAgent.setContinueSessionMillis(millis); - } + @Override + public void stopSession() { + LogD("stopSession invoked!"); + FlurryAgent.onEndSession(mContext); + } - @Override - public void setCaptureUncaughtException(boolean isEnabled) { - LogD("setCaptureUncaughtException invoked!"); - FlurryAgent.setCaptureUncaughtExceptions(isEnabled); - } + @Override + public void setSessionContinueMillis(int millis) { + LogD("setSessionContinueMillis invoked!"); + FlurryAgent.setContinueSessionMillis(millis); + } - @Override - public void setDebugMode(boolean isDebugMode) { - isDebug = isDebugMode; - FlurryAgent.setLogEnabled(isDebug); - if (isDebugMode) { - FlurryAgent.setLogLevel(Log.DEBUG); - } - } + @Override + public void setCaptureUncaughtException(boolean isEnabled) { + LogD("setCaptureUncaughtException invoked!"); + FlurryAgent.setCaptureUncaughtExceptions(isEnabled); + } - @Override - public void logError(String errorId, String message) { - LogD("logError invoked!"); - FlurryAgent.onError(errorId, message, ""); - } + @Override + public void setDebugMode(boolean isDebugMode) { + isDebug = isDebugMode; + FlurryAgent.setLogEnabled(isDebug); + if (isDebugMode) { + FlurryAgent.setLogLevel(Log.DEBUG); + } + } - @Override - public void logEvent(String eventId) { - LogD("logEvent(eventId) invoked!"); - FlurryAgent.logEvent(eventId); - } + @Override + public void logError(String errorId, String message) { + LogD("logError invoked!"); + FlurryAgent.onError(errorId, message, ""); + } - @Override - public void logEvent(String eventId, Hashtable paramMap) { - LogD("logEvent(eventId, paramMap) invoked!"); - FlurryAgent.logEvent(eventId, paramMap); - } + @Override + public void logEvent(String eventId) { + LogD("logEvent(eventId) invoked!"); + FlurryAgent.logEvent(eventId); + } - @Override - public void logTimedEventBegin(String eventId) { - LogD("logTimedEventBegin invoked!"); - FlurryAgent.logEvent(eventId, true); - } + @Override + public void logEvent(String eventId, Hashtable paramMap) { + LogD("logEvent(eventId, paramMap) invoked!"); + FlurryAgent.logEvent(eventId, paramMap); + } - @Override - public void logTimedEventEnd(String eventId) { - LogD("logTimedEventEnd invoked!"); - FlurryAgent.endTimedEvent(eventId); - } + @Override + public void logTimedEventBegin(String eventId) { + LogD("logTimedEventBegin invoked!"); + FlurryAgent.logEvent(eventId, true); + } - @Override - public String getSDKVersion() { - LogD("getSDKVersion invoked!"); - String ret = ""; - try { - int nRet = FlurryAgent.getAgentVersion(); - ret = "Flurry android ver " + nRet; - } catch(Exception e){ - LogE("Exception in getSDKVersion", e); - } - return ret; - } + @Override + public void logTimedEventEnd(String eventId) { + LogD("logTimedEventEnd invoked!"); + FlurryAgent.endTimedEvent(eventId); + } - protected void logTimedEventBegin(String eventId, Hashtable paramMap) { - LogD("logTimedEventBegin invoked!"); - try{ - FlurryAgent.logEvent(eventId, paramMap, true); - } catch(Exception e){ - LogE("Exception in logTimedEventBegin", e); - } - } - - protected void setReportLocation(boolean enabled) { - LogD("setReportLocation invoked!"); - try{ - FlurryAgent.setReportLocation(enabled); - } catch(Exception e){ - LogE("Exception in setReportLocation", e); - } - } - - protected void logPageView() { - LogD("logPageView invoked!"); - try{ - FlurryAgent.onPageView(); - } catch(Exception e){ - LogE("Exception in logPageView", e); - } - } + @Override + public String getSDKVersion() { + LogD("getSDKVersion invoked!"); + String ret = ""; + try { + int nRet = FlurryAgent.getAgentVersion(); + ret = "Flurry android ver " + nRet; + } catch(Exception e){ + LogE("Exception in getSDKVersion", e); + } + return ret; + } - protected void setVersionName(String versionName) { - LogD("setVersionName invoked!"); - try { - FlurryAgent.setVersionName(versionName); - } catch(Exception e){ - LogE("Exception in setVersionName", e); - } - } - - protected void setAge(int age) { - LogD("setAge invoked!"); - try { - FlurryAgent.setAge(age); - } catch(Exception e){ - LogE("Exception in setAge", e); - } - } - - protected void setGender(byte gender) { - LogD("setGender invoked!"); - try { - FlurryAgent.setGender(gender); - } catch(Exception e){ - LogE("Exception in setGender", e); - } - } - - protected void setUserId(String userId) { - LogD("setUserId invoked!"); - try { - FlurryAgent.setUserId(userId); - } catch(Exception e){ - LogE("Exception in setUserId", e); - } - } - - protected void setUseHttps(boolean useHttps) { - LogD("setUseHttps invoked!"); - try { - FlurryAgent.setUseHttps(useHttps); - } catch(Exception e){ - LogE("Exception in setUseHttps", e); - } - } + protected void logTimedEventBeginWithParams(JSONObject eventInfo) { + LogD("logTimedEventBegin invoked!"); + try{ + String eventId = eventInfo.getString("Param1"); + + if (eventInfo.has("Param2")) + { + JSONObject params = eventInfo.getJSONObject("Param2"); + @SuppressWarnings("rawtypes") + Iterator it = params.keys(); + Hashtable paramMap = new Hashtable(); + 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!"); + try{ + FlurryAgent.setReportLocation(enabled); + } catch(Exception e){ + LogE("Exception in setReportLocation", e); + } + } + + protected void logPageView() { + LogD("logPageView invoked!"); + try{ + FlurryAgent.onPageView(); + } catch(Exception e){ + LogE("Exception in logPageView", e); + } + } + + protected void setVersionName(String versionName) { + LogD("setVersionName invoked!"); + try { + FlurryAgent.setVersionName(versionName); + } catch(Exception e){ + LogE("Exception in setVersionName", e); + } + } + + protected void setAge(int age) { + LogD("setAge invoked!"); + try { + FlurryAgent.setAge(age); + } catch(Exception e){ + LogE("Exception in setAge", e); + } + } + + protected void setGender(byte gender) { + LogD("setGender invoked!"); + try { + FlurryAgent.setGender(gender); + } catch(Exception e){ + LogE("Exception in setGender", e); + } + } + + protected void setUserId(String userId) { + LogD("setUserId invoked!"); + try { + FlurryAgent.setUserId(userId); + } catch(Exception e){ + LogE("Exception in setUserId", e); + } + } + + protected void setUseHttps(boolean useHttps) { + LogD("setUseHttps invoked!"); + try { + FlurryAgent.setUseHttps(useHttps); + } catch(Exception e){ + LogE("Exception in setUseHttps", e); + } + } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/flurry/platform/ios/FlurryWrapper.h b/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.h similarity index 79% rename from plugin/plugins/flurry/platform/ios/FlurryWrapper.h rename to plugin/plugins/flurry/proj.ios/AnalyticsFlurry.h index 3a9da52a6f..43686919da 100644 --- a/plugin/plugins/flurry/platform/ios/FlurryWrapper.h +++ b/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.h @@ -23,25 +23,28 @@ THE SOFTWARE. ****************************************************************************/ #import "InterfaceAnalytics.h" -@interface FlurryWrapper : NSObject +@interface AnalyticsFlurry : NSObject { } +@property BOOL debug; + /** interfaces of protocol : InterfaceAnalytics */ - (void) startSession: (NSString*) appKey; - (void) stopSession; -- (void) setSessionContinueMillis: (NSNumber*) millis; -- (void) setCaptureUncaughtException: (NSNumber*) isEnabled; -- (void) setDebugMode: (NSNumber*) isDebugMode; +- (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 @@ -49,9 +52,10 @@ THE SOFTWARE. - (void) setAge: (NSNumber*) age; - (void) setGender: (NSString*) gender; - (void) setUserId: (NSString*) userId; +- (void) setUseHttps: (NSNumber*) enabled; - (void) logPageView; - (void) setVersionName: (NSString*) versionName; -- (void) logTimedEventBegin: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap; -- (void) logTimedEventEnd: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap; +- (void) logTimedEventBeginWithParams: (NSMutableDictionary*) params; +- (void) logTimedEventEndWithParams: (NSMutableDictionary*) params; @end diff --git a/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.m b/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.m new file mode 100644 index 0000000000..1ce6df0b9c --- /dev/null +++ b/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.m @@ -0,0 +1,166 @@ +/**************************************************************************** +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 [Flurry getFlurryAgentVersion]; +} + +- (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: (NSString*) gender +{ + OUTPUT_LOG(@"Flurry setGender invoked (%@)", gender); + [Flurry setGender:gender]; +} + +- (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 diff --git a/plugin/plugins/flurry/platform/ios/Flurry.h b/plugin/plugins/flurry/proj.ios/Flurry.h similarity index 100% rename from plugin/plugins/flurry/platform/ios/Flurry.h rename to plugin/plugins/flurry/proj.ios/Flurry.h diff --git a/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj b/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj index eb8e0bdb3b..ddeb98acd6 100644 --- a/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj +++ b/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj @@ -8,9 +8,8 @@ /* Begin PBXBuildFile section */ FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A375168AFD41008C1C7B /* Foundation.framework */; }; - FA09A394168B00D4008C1C7B /* AnalyticsFlurry.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA09A393168B00D4008C1C7B /* AnalyticsFlurry.mm */; }; - FA866509168BE0980073E055 /* libFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA866508168BE0980073E055 /* libFlurry.a */; }; - FA8CC2241739EFF200464206 /* FlurryWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC2231739EFF200464206 /* FlurryWrapper.m */; }; + 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 */ @@ -28,13 +27,11 @@ /* 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; }; - FA09A391168AFD79008C1C7B /* AnalyticsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsFlurry.h; sourceTree = ""; }; - FA09A393168B00D4008C1C7B /* AnalyticsFlurry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnalyticsFlurry.mm; sourceTree = ""; }; - FA866507168BE0980073E055 /* Flurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flurry.h; sourceTree = ""; }; - FA866508168BE0980073E055 /* libFlurry.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry.a; sourceTree = ""; }; FA86650E168BE22D0073E055 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; - FA8CC2221739EFF200464206 /* FlurryWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryWrapper.h; sourceTree = ""; }; - FA8CC2231739EFF200464206 /* FlurryWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlurryWrapper.m; sourceTree = ""; }; + FAB6DFD81756F22200C90D89 /* Flurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flurry.h; sourceTree = ""; }; + FAB6DFDB1756F22200C90D89 /* libFlurry.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry.a; sourceTree = ""; }; + FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsFlurry.h; sourceTree = ""; }; + FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnalyticsFlurry.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -43,7 +40,7 @@ buildActionMask = 2147483647; files = ( FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */, - FA866509168BE0980073E055 /* libFlurry.a in Frameworks */, + FAB6DFDD1756F22200C90D89 /* libFlurry.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -53,9 +50,11 @@ FA09A367168AFD41008C1C7B = { isa = PBXGroup; children = ( + FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */, + FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */, + FAB6DFD81756F22200C90D89 /* Flurry.h */, + FAB6DFDB1756F22200C90D89 /* libFlurry.a */, FA86650E168BE22D0073E055 /* SystemConfiguration.framework */, - FA09A392168AFD96008C1C7B /* ios */, - FA09A390168AFD79008C1C7B /* include */, FA09A374168AFD41008C1C7B /* Frameworks */, FA09A373168AFD41008C1C7B /* Products */, ); @@ -77,28 +76,6 @@ name = Frameworks; sourceTree = ""; }; - FA09A390168AFD79008C1C7B /* include */ = { - isa = PBXGroup; - children = ( - FA09A391168AFD79008C1C7B /* AnalyticsFlurry.h */, - ); - name = include; - path = ../include; - sourceTree = ""; - }; - FA09A392168AFD96008C1C7B /* ios */ = { - isa = PBXGroup; - children = ( - FA8CC2221739EFF200464206 /* FlurryWrapper.h */, - FA8CC2231739EFF200464206 /* FlurryWrapper.m */, - FA866507168BE0980073E055 /* Flurry.h */, - FA866508168BE0980073E055 /* libFlurry.a */, - FA09A393168B00D4008C1C7B /* AnalyticsFlurry.mm */, - ); - name = ios; - path = ../platform/ios; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -150,8 +127,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - FA09A394168B00D4008C1C7B /* AnalyticsFlurry.mm in Sources */, - FA8CC2241739EFF200464206 /* FlurryWrapper.m in Sources */, + FAB6DFE01756F29800C90D89 /* AnalyticsFlurry.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -215,6 +191,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../platform/ios\"", + "\"$(SRCROOT)\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = PluginFlurry; @@ -235,6 +212,7 @@ LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../platform/ios\"", + "\"$(SRCROOT)\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = PluginFlurry; diff --git a/plugin/plugins/flurry/platform/ios/libFlurry.a.REMOVED.git-id b/plugin/plugins/flurry/proj.ios/libFlurry.a.REMOVED.git-id similarity index 100% rename from plugin/plugins/flurry/platform/ios/libFlurry.a.REMOVED.git-id rename to plugin/plugins/flurry/proj.ios/libFlurry.a.REMOVED.git-id diff --git a/plugin/plugins/nd91/include/IAPNd91.h b/plugin/plugins/nd91/include/IAPNd91.h deleted file mode 100644 index 2b81a65124..0000000000 --- a/plugin/plugins/nd91/include/IAPNd91.h +++ /dev/null @@ -1,82 +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. -****************************************************************************/ -#ifndef __CCX_IAP_ND91_H__ -#define __CCX_IAP_ND91_H__ - -#include "ProtocolIAP.h" -#include -#include - -namespace cocos2d { namespace plugin { - -class IAPNd91 : public ProtocolIAP -{ - PLUGIN_REGISTER_DECL(IAPNd91) -public: - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief config the developer info - @param devInfo This parameter is the info of developer, must contains key: - Nd91AppId The app id of nd91 - Nd91AppKey The app key of nd91 - Nd91Orientation The orientation of your app(use value : portrait, landscape, auto) - default value is portrait - @warning Must invoke this interface before other interfaces. - And invoked only once. - */ - virtual void configDeveloperInfo(TIAPDeveloperInfo devInfo); - - /** - @brief pay for product - @param info The info of product, must contains key: - productName The name of product - productPrice The price of product(must can be parse to float) - productDesc The description of product - Nd91ProductId The product id of product for nd91 - Nd91ProductCount The product number will buy(1--10000, default value 1) - Nd91OriginalPrice The original price of product(default value is same with productPrice) - @warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. - */ - virtual void payForProduct(TProductInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - virtual ~IAPNd91(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_IAP_ND91_H__ */ diff --git a/plugin/plugins/nd91/jsb_nd91.ini b/plugin/plugins/nd91/jsb_nd91.ini deleted file mode 100644 index 0949203dab..0000000000 --- a/plugin/plugins/nd91/jsb_nd91.ini +++ /dev/null @@ -1,59 +0,0 @@ -[nd91] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_nd91 - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/nd91/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/nd91/include/IAPNd91.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = IAPNd91 - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = IAPNd91 - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes diff --git a/plugin/plugins/nd91/platform/android/DependProject/.settings/org.eclipse.jdt.core.prefs b/plugin/plugins/nd91/platform/android/DependProject/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8000cd6ca6..0000000000 --- a/plugin/plugins/nd91/platform/android/DependProject/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/plugin/plugins/nd91/platform/android/IAPNd91.cpp b/plugin/plugins/nd91/platform/android/IAPNd91.cpp deleted file mode 100644 index 664a03e9ba..0000000000 --- a/plugin/plugins/nd91/platform/android/IAPNd91.cpp +++ /dev/null @@ -1,85 +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. -****************************************************************************/ -#include "IAPNd91.h" -#include "PluginUtils.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(IAPNd91) - -IAPNd91::~IAPNd91() -{ -} - -/** -@brief plugin initialization -*/ -bool IAPNd91::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.IAPNd91"); -} - -/** -@brief config the developer info -@param devInfo This parameter is the info of developer, must contains key: - Nd91AppId The app id of nd91 - Nd91AppKey The app key of nd91 - Nd91Orientation The orientation of your app(use value : portrait, landscape, auto) - default value is portrait -@warning Must invoke this interface before other interfaces. - And invoked only once. -*/ -void IAPNd91::configDeveloperInfo(TIAPDeveloperInfo devInfo) -{ - ProtocolIAP::configDeveloperInfo(devInfo); -} - -/** -@brief pay for product -@param info The info of product, must contains key: - productName The name of product - productPrice The price of product(must can be parse to float) - productDesc The description of product - Nd91ProductId The product id of product for nd91 - Nd91ProductCount The product number will buy(1--10000) - Nd91OriginalPrice The original price of product -@warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. -*/ -void IAPNd91::payForProduct(TProductInfo info) -{ - ProtocolIAP::payForProduct(info); -} - -const char* IAPNd91::getSDKVersion() -{ - return ProtocolIAP::getSDKVersion(); -} - -void IAPNd91::setDebugMode(bool debug) -{ - ProtocolIAP::setDebugMode(debug); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/nd91/proj.android/.project b/plugin/plugins/nd91/proj.android/.project index 89ad77c006..af04421e09 100644 --- a/plugin/plugins/nd91/proj.android/.project +++ b/plugin/plugins/nd91/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/nd91/platform/android/DependProject/.classpath b/plugin/plugins/nd91/proj.android/DependProject/.classpath similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/.classpath rename to plugin/plugins/nd91/proj.android/DependProject/.classpath diff --git a/plugin/plugins/nd91/platform/android/DependProject/.project b/plugin/plugins/nd91/proj.android/DependProject/.project similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/.project rename to plugin/plugins/nd91/proj.android/DependProject/.project diff --git a/plugin/plugins/nd91/platform/android/DependProject/AndroidManifest.xml b/plugin/plugins/nd91/proj.android/DependProject/AndroidManifest.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/AndroidManifest.xml rename to plugin/plugins/nd91/proj.android/DependProject/AndroidManifest.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/project.properties b/plugin/plugins/nd91/proj.android/DependProject/project.properties similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/project.properties rename to plugin/plugins/nd91/proj.android/DependProject/project.properties diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipin.xml b/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipin.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipin_reverse.xml b/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin_reverse.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipin_reverse.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin_reverse.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipout.xml b/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipout.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipout_reverse.xml b/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout_reverse.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/anim/nd_flipout_reverse.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout_reverse.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_background_xml.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_background_xml.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_background_xml.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_background_xml.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_02.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_02.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_02.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_02.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_action.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_action.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_action.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_action.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_logout.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_logout.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_logout.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_logout.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_old.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_old.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_old.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_old.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_x.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_x.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_button_x.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_x.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_checkbox_button.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_checkbox_button.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_checkbox_button.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_checkbox_button.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_friend_del_button.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_friend_del_button.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_friend_del_button.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_friend_del_button.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_image_48_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_image_48_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_image_48_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_image_48_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_input_gray.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_input_gray.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_input_gray.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_input_gray.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_message_item_1_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_1_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_message_item_1_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_1_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_message_item_2_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_2_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_message_item_2_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_2_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_pay_checkbox_button.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_pay_checkbox_button.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_pay_checkbox_button.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_pay_checkbox_button.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_progress_large.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_progress_large.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_progress_large.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_progress_large.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_left_btn_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_left_btn_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_left_btn_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_left_btn_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_middle_btn_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_middle_btn_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_middle_btn_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_middle_btn_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_right_btn_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_right_btn_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_rank_choice_right_btn_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_right_btn_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_regist_checked.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_regist_checked.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_regist_checked.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_regist_checked.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_round_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_round_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_round_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_round_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_square_checkbox_button.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_square_checkbox_button.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_square_checkbox_button.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_square_checkbox_button.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_title_bar_action_btn_xml.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_action_btn_xml.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_title_bar_action_btn_xml.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_action_btn_xml.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_title_bar_return_btn_xml.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_return_btn_xml.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_title_bar_return_btn_xml.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_return_btn_xml.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_user_item_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_user_item_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd3_user_item_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_user_item_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_blue.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_blue.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_blue.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_blue.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_add.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_add.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_add.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_add.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_buy.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_buy.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_buy.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_buy.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_reduce.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_reduce.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_button_action_reduce.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_reduce.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_c_blur.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_c_blur.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_c_blur.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_c_blur.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_download.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_download.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_download.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_download.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_green.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_green.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_green.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_green.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_leaderboard_left_btn_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_left_btn_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_leaderboard_left_btn_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_left_btn_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_leaderboard_right_btn_bg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_right_btn_bg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_leaderboard_right_btn_bg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_right_btn_bg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_list_btn_delete_selector.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_list_btn_delete_selector.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_list_btn_delete_selector.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_list_btn_delete_selector.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_login_btn_land_selector.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_land_selector.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_login_btn_land_selector.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_land_selector.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_login_btn_portrait_selector.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_portrait_selector.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_login_btn_portrait_selector.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_portrait_selector.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_register_btn_portrait_selector.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_register_btn_portrait_selector.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_register_btn_portrait_selector.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_register_btn_portrait_selector.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_h.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_h.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_h_expand.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h_expand.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_h_expand.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h_expand.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_v.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_v.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_v_expand.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v_expand.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_slider_handle_v_expand.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v_expand.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_white_btn.xml b/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_white_btn.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/drawable/nd_white_btn.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_white_btn.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_bind_bind.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_bind.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_bind_bind.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_bind.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_bind_register.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_register.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_bind_register.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_register.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_email_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_email_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_email_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_email_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_land.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_land.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_land.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_land.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_other_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_other_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_other_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_other_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_portrait.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_portrait.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_login_portrait.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_portrait.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_oauth_bind.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_oauth_bind.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_oauth_bind.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_oauth_bind.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official_landscape.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official_landscape.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official_landscape.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official_landscape.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official_portrait.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official_portrait.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_official_portrait.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official_portrait.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_other_login.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_other_login.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_other_login.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_other_login.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_agreement.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_agreement.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_agreement.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_agreement.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_phone.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_phone.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_phone.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_phone.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_quick.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_quick.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_register_quick.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_register_quick.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_secret_find.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_secret_find.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_secret_find.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_secret_find.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_secret_set.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_secret_set.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_secret_set.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_secret_set.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_sina.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_sina.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_account_sina.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_sina.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_achieve_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_achieve_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_achieve_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_achieve_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_action_template.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_action_template.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_action_template.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_action_template.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_1.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_1.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_1.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_1.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_2.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_2.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_2.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_2.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_2_ext.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_2_ext.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_2_ext.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_2_ext.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_3.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_3.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_3.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_3.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_4.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_4.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_content_reg_template_4.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_content_reg_template_4.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_image.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_image.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_image.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_image.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_list.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_list.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_list.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_list.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_list_ext.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_list_ext.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_detail_plus_list_ext.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_detail_plus_list_ext.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_head_reg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_head_reg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_head_reg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_head_reg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_no_action_template.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_no_action_template.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_activity_no_action_template.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_activity_no_action_template.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_feedback.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_feedback.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_feedback.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_feedback.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_property.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_property.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_app_property.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_app_property.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_banner_layout.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_banner_layout.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_banner_layout.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_banner_layout.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_blank_listview.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_blank_listview.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_blank_listview.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_blank_listview.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_bottom_bar.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_bottom_bar.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_bottom_bar.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_bottom_bar.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_category_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_category_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_category_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_category_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_category_plus_image_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_category_plus_image_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_category_plus_image_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_category_plus_image_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_control_center.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_control_center.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_control_center.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_control_center.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_dispatch_search_friend.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_dispatch_search_friend.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_dispatch_search_friend.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_dispatch_search_friend.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_empty_listview.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_empty_listview.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_empty_listview.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_empty_listview.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_frame.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_frame.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_frame.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_frame.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_home.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_home.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_home.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_home.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_remark_setting.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_remark_setting.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_remark_setting.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_remark_setting.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section_list_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section_list_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section_list_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section_list_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section_panel.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section_panel.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_friend_section_panel.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_friend_section_panel.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_game_content.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_game_content.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_game_content.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_game_content.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_game_main.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_game_main.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_game_main.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_game_main.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_land.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_land.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_land.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_land.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_personal.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_personal.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_personal.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_personal.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_portrait.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_portrait.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_home_portrait.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_home_portrait.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend_choice.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend_choice.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend_choice.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend_choice.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_invite_friend_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_invite_friend_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_leaderboard_category.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_leaderboard_category.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_leaderboard_category.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_leaderboard_category.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_leaderboard_list_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_leaderboard_list_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_leaderboard_list_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_leaderboard_list_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_footer.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_footer.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_footer.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_footer.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_footer_ext.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_footer_ext.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_footer_ext.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_footer_ext.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_template.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_template.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_template.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_template.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_template_no_divider.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_template_no_divider.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_listview_template_no_divider.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_listview_template_no_divider.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_mesg_main.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_mesg_main.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_mesg_main.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_mesg_main.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_friendmsge_list.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_friendmsge_list.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_friendmsge_list.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_friendmsge_list.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_main.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_main.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_main.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_main.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_receive_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_receive_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_receive_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_receive_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_record_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_record_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_record_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_record_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_send.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_send.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_send.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_send.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_send_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_send_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_message_send_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_message_send_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_about.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_about.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_about.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_about.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_account.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_account.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_account.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_account.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_bean_recharge.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_bean_recharge.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_bean_recharge.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_bean_recharge.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_consume_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_consume_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_consume_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_consume_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_consumes.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_consumes.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_consumes.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_consumes.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_info.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_info.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_info.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_info.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_info_edit_head_dialog.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_info_edit_head_dialog.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_info_edit_head_dialog.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_info_edit_head_dialog.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_more.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_more.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_more.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_more.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_no_password.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_no_password.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_no_password.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_no_password.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_password.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_password.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_password.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_password.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_permission.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_permission.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_permission.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_permission.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_recharge_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_recharge_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_recharge_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_recharge_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_recharges.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_recharges.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_recharges.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_recharges.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_records.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_records.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_records.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_records.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_records_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_records_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_more_records_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_more_records_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_myfriend.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_myfriend.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_myfriend.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_myfriend.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_network_error.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_network_error.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_network_error.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_network_error.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_normal_search.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_normal_search.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_normal_search.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_normal_search.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_friend_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_friend_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_friend_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_friend_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_pass.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_pass.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_pass.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_pass.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_password_check.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_password_check.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_password_check.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_password_check.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_products_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_products_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_products_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_products_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_select_friend.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_select_friend.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_select_friend.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_select_friend.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_template.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_template.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_pay_template.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_pay_template.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_person_info_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_person_info_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_person_info_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_person_info_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_personinfo.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_personinfo.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_personinfo.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_personinfo.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_progressbar.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_progressbar.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_progressbar.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_progressbar.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_recharge_record.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_recharge_record.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_recharge_record.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_recharge_record.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_searchfriend_condition.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_searchfriend_condition.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_searchfriend_condition.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_searchfriend_condition.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_bind_account_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_bind_account_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_bind_account_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_bind_account_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_sina.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_sina.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_sina.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_sina.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_unbind_account_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_unbind_account_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_share_unbind_account_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_share_unbind_account_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_stranger_home.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_stranger_home.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_stranger_home.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_stranger_home.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_action.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_action.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_action.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_action.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_app.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_app.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_app.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_app.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_no_action.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_no_action.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_detail_no_action.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_detail_no_action.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_head_reg.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_head_reg.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_sysmessage_head_reg.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_sysmessage_head_reg.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_thirdplatform_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_thirdplatform_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_thirdplatform_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_thirdplatform_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_title_bar.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_title_bar.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_title_bar.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_title_bar.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_fangle.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_fangle.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_fangle_ext.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle_ext.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_fangle_ext.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle_ext.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_item_divider.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item_divider.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_item_divider.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item_divider.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_message.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_message.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_message_switcher.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message_switcher.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_user_message_switcher.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message_switcher.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_version_update.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_version_update.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_version_update.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_version_update.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_write_message.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_write_message.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd3_write_message.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_write_message.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_account_list_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_account_list_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_account_list_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_account_list_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_account_manage.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_account_manage.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_account_manage.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_account_manage.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_lottery.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_lottery.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_lottery.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_lottery.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_result.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_result.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_result.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_result.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_tip.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_tip.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_tip.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_tip.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_unactivity_tip.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_unactivity_tip.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_bind_phone_number_unactivity_tip.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_bind_phone_number_unactivity_tip.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_check_version.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_check_version.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_check_version.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_check_version.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_find_password.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_find_password.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_find_password.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_find_password.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_detail.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_detail.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_detail.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_detail.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_list.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_list.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_list.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_list.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_list_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_list_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_goods_list_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_goods_list_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_list_header.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_list_header.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_list_header.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_list_header.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_switcher_landscape_1.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_switcher_landscape_1.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_switcher_landscape_1.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_switcher_landscape_1.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_switcher_portrait_1.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_switcher_portrait_1.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_leaderboard_switcher_portrait_1.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_leaderboard_switcher_portrait_1.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_login_director.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_login_director.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_login_director.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_login_director.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_set_password.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_set_password.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_set_password.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_set_password.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_flipitem.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_flipitem.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_flipitem.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_flipitem.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_listitem.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_listitem.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_listitem.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_listitem.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_h.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_h.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_h.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_h.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_item.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_item.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_item.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_item.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_v.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_v.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softpromotion_slider_v.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softpromotion_slider_v.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softwarepromotion.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softwarepromotion.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_softwarepromotion.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_softwarepromotion.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_unbind_phone_number.xml b/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_unbind_phone_number.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/layout/nd_unbind_phone_number.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/layout/nd_unbind_phone_number.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/raw/nd_res.zip b/plugin/plugins/nd91/proj.android/DependProject/res/raw/nd_res.zip similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/raw/nd_res.zip rename to plugin/plugins/nd91/proj.android/DependProject/res/raw/nd_res.zip diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_misc.xml b/plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_misc.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_misc.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_misc.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_sdk_error_strings.xml b/plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_sdk_error_strings.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_sdk_error_strings.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_sdk_error_strings.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_strings.xml b/plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_strings.xml similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/res/values/nd3_strings.xml rename to plugin/plugins/nd91/proj.android/DependProject/res/values/nd3_strings.xml diff --git a/plugin/plugins/nd91/platform/android/DependProject/src/.gitignore b/plugin/plugins/nd91/proj.android/DependProject/src/.gitignore similarity index 100% rename from plugin/plugins/nd91/platform/android/DependProject/src/.gitignore rename to plugin/plugins/nd91/proj.android/DependProject/src/.gitignore diff --git a/plugin/plugins/nd91/proj.android/build_native.sh b/plugin/plugins/nd91/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/nd91/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/nd91/proj.android/jni/Android.mk b/plugin/plugins/nd91/proj.android/jni/Android.mk deleted file mode 100644 index 5f3d3ffcff..0000000000 --- a/plugin/plugins/nd91/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginNd91Static - -LOCAL_MODULE_FILENAME := libPluginNd91Static - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - IAPNd91.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/nd91/proj.android/jni/Application.mk b/plugin/plugins/nd91/proj.android/jni/Application.mk deleted file mode 100644 index c99caa634c..0000000000 --- a/plugin/plugins/nd91/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginNd91Static -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/nd91/proj.android/src/org/cocos2dx/plugin/IAPNd91.java b/plugin/plugins/nd91/proj.android/src/org/cocos2dx/plugin/IAPNd91.java index aa2a8335af..c60c1e4348 100644 --- a/plugin/plugins/nd91/proj.android/src/org/cocos2dx/plugin/IAPNd91.java +++ b/plugin/plugins/nd91/proj.android/src/org/cocos2dx/plugin/IAPNd91.java @@ -26,8 +26,6 @@ package org.cocos2dx.plugin; import java.util.Hashtable; import java.util.UUID; -import org.cocos2dx.plugin.InterfaceIAP.IAPAdapter; - import com.nd.commplatform.NdCommplatform; import com.nd.commplatform.NdErrorCode; import com.nd.commplatform.NdMiscCallbackListener; @@ -40,7 +38,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; -public class IAPNd91 implements IAPAdapter { +public class IAPNd91 implements InterfaceIAP { private static final String LOG_TAG = "IAPNd91"; private static Activity mContext = null; @@ -104,13 +102,13 @@ public class IAPNd91 implements IAPAdapter { public void payForProduct(Hashtable info) { LogD("payForProduct invoked " + info.toString()); if (! networkReachable()) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "网络不可用"); + payResult(IAPWrapper.PAYRESULT_FAIL, "网络不可用"); return; } curProductInfo = info; if (curProductInfo == null) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "商品信息错误"); + payResult(IAPWrapper.PAYRESULT_FAIL, "商品信息错误"); return; } @@ -150,7 +148,7 @@ public class IAPNd91 implements IAPAdapter { } private static void payResult(int ret, String msg) { - InterfaceIAP.onPayResult(mNd91, ret, msg); + IAPWrapper.onPayResult(mNd91, ret, msg); LogD("Nd91 result : " + ret + " msg : " + msg); } @@ -176,14 +174,14 @@ public class IAPNd91 implements IAPAdapter { if (code == NdErrorCode.ND_COM_PLATFORM_SUCCESS) { addPayment(curProductInfo); } else if (code == NdErrorCode.ND_COM_PLATFORM_ERROR_CANCEL) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "用户取消登录"); + payResult(IAPWrapper.PAYRESULT_FAIL, "用户取消登录"); } else { - payResult(InterfaceIAP.PAYRESULT_FAIL, "用户登录失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "用户登录失败"); } } }); } catch (Exception e) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "用户登录失败"); + payResult(IAPWrapper.PAYRESULT_FAIL, "用户登录失败"); LogE("User login error", e); } } @@ -199,7 +197,7 @@ public class IAPNd91 implements IAPAdapter { String strCount = productInfo.get("Nd91ProductCount"); if (id == null || id.length() == 0) { - payResult(InterfaceIAP.PAYRESULT_FAIL, "商品信息错误"); + payResult(IAPWrapper.PAYRESULT_FAIL, "商品信息错误"); break; } @@ -230,24 +228,29 @@ public class IAPNd91 implements IAPAdapter { IAPNd91.LogD("finishPayProcess code : " + code); switch(code){ case NdErrorCode.ND_COM_PLATFORM_SUCCESS: - IAPNd91.payResult(InterfaceIAP.PAYRESULT_SUCCESS, "购买成功"); + IAPNd91.payResult(IAPWrapper.PAYRESULT_SUCCESS, "购买成功"); break; case NdErrorCode.ND_COM_PLATFORM_ERROR_PAY_FAILURE: - IAPNd91.payResult(InterfaceIAP.PAYRESULT_FAIL, "购买失败"); break; + IAPNd91.payResult(IAPWrapper.PAYRESULT_FAIL, "购买失败"); break; case NdErrorCode.ND_COM_PLATFORM_ERROR_PAY_CANCEL: - IAPNd91.payResult(InterfaceIAP.PAYRESULT_CANCEL, "取消购买"); break; + IAPNd91.payResult(IAPWrapper.PAYRESULT_CANCEL, "取消购买"); break; default: - IAPNd91.payResult(InterfaceIAP.PAYRESULT_FAIL, "购买失败"); break; + IAPNd91.payResult(IAPWrapper.PAYRESULT_FAIL, "购买失败"); break; } } }); if (aError != 0) { - IAPNd91.payResult(InterfaceIAP.PAYRESULT_FAIL, "您输入参数有错,无法提交购买请求"); + IAPNd91.payResult(IAPWrapper.PAYRESULT_FAIL, "您输入参数有错,无法提交购买请求"); } } while (false); } catch (Exception e) { LogE("Error during payment", e); - IAPNd91.payResult(InterfaceIAP.PAYRESULT_FAIL, "支付失败"); + IAPNd91.payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); } } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/twitter/include/SocialTwitter.h b/plugin/plugins/twitter/include/SocialTwitter.h deleted file mode 100755 index 6487741d0c..0000000000 --- a/plugin/plugins/twitter/include/SocialTwitter.h +++ /dev/null @@ -1,76 +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. -****************************************************************************/ -#ifndef __CCX_SOCIAL_TWITTER_H__ -#define __CCX_SOCIAL_TWITTER_H__ - -#include "ProtocolSocial.h" -#include -#include - -namespace cocos2d { namespace plugin { - -class SocialTwitter : public ProtocolSocial -{ - PLUGIN_REGISTER_DECL(SocialTwitter) -public: - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief config the developer info - @param devInfo This parameter is the info of developer, must contains key: - TwitterKey The consumerkey of twitter account - TwitterSecret The consumersecret of twitter account - @warning Must invoke this interface before other interfaces. - And invoked only once. - */ - virtual void configDeveloperInfo(TSocialDeveloperInfo devInfo); - - /** - @brief pay for product - @param info The info of product, can contains key: - SharedText The text need to share - SharedImagePath The full path of image file need to share (optinal) - @warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. - */ - virtual void share(TShareInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - virtual ~SocialTwitter(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_SOCIAL_TWITTER_H__ */ diff --git a/plugin/plugins/twitter/jsb_twitter.ini b/plugin/plugins/twitter/jsb_twitter.ini deleted file mode 100644 index 01d3058c96..0000000000 --- a/plugin/plugins/twitter/jsb_twitter.ini +++ /dev/null @@ -1,60 +0,0 @@ -[twitter] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_twitter - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/twitter/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/twitter/include/SocialTwitter.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = SocialTwitter - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = SocialTwitter - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes - diff --git a/plugin/plugins/twitter/platform/android/SocialTwitter.cpp b/plugin/plugins/twitter/platform/android/SocialTwitter.cpp deleted file mode 100755 index 7d7bfafa0d..0000000000 --- a/plugin/plugins/twitter/platform/android/SocialTwitter.cpp +++ /dev/null @@ -1,78 +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. -****************************************************************************/ -#include "SocialTwitter.h" -#include "PluginUtils.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(SocialTwitter) - -SocialTwitter::~SocialTwitter() -{ -} - -/** -@brief plugin initialization -*/ -bool SocialTwitter::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.SocialTwitter"); -} - -/** -@brief config the developer info -@param devInfo This parameter is the info of developer, must contains key: - TwitterKey The consumerkey of twitter account - TwitterSecret The consumersecret of twitter account - More: https://dev.twitter.com -@warning Must invoke this interface before other interfaces. - And invoked only once. -*/ -void SocialTwitter::configDeveloperInfo(TSocialDeveloperInfo devInfo) -{ - ProtocolSocial::configDeveloperInfo(devInfo); -} - -/** -@brief pay for product -@param info The info of product, must contains key: - SharedText The text need to share - SharedImagePath The full path of image file need to share (optinal) -*/ -void SocialTwitter::share(TShareInfo info) -{ - ProtocolSocial::share(info); -} - -const char* SocialTwitter::getSDKVersion() -{ - return ProtocolSocial::getSDKVersion(); -} - -void SocialTwitter::setDebugMode(bool debug) -{ - ProtocolSocial::setDebugMode(debug); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/twitter/proj.android/.project b/plugin/plugins/twitter/proj.android/.project index 9aade58531..a46974059c 100755 --- a/plugin/plugins/twitter/proj.android/.project +++ b/plugin/plugins/twitter/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/twitter/proj.android/build_native.sh b/plugin/plugins/twitter/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/twitter/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/twitter/proj.android/jni/Android.mk b/plugin/plugins/twitter/proj.android/jni/Android.mk deleted file mode 100755 index e4c920eb4c..0000000000 --- a/plugin/plugins/twitter/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginTwitterStatic - -LOCAL_MODULE_FILENAME := libPluginTwitterStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - SocialTwitter.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/twitter/proj.android/jni/Application.mk b/plugin/plugins/twitter/proj.android/jni/Application.mk deleted file mode 100755 index e4935028c3..0000000000 --- a/plugin/plugins/twitter/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginTwitterStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/twitter/proj.android/src/org/cocos2dx/plugin/SocialTwitter.java b/plugin/plugins/twitter/proj.android/src/org/cocos2dx/plugin/SocialTwitter.java index d539e6f016..b799bbd151 100755 --- a/plugin/plugins/twitter/proj.android/src/org/cocos2dx/plugin/SocialTwitter.java +++ b/plugin/plugins/twitter/proj.android/src/org/cocos2dx/plugin/SocialTwitter.java @@ -25,7 +25,6 @@ package org.cocos2dx.plugin; import java.util.Hashtable; -import org.cocos2dx.plugin.InterfaceSocial.ShareAdapter; import org.cocos2dx.plugin.TwitterApp.TwDialogListener; import android.app.Activity; @@ -34,11 +33,11 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; -public class SocialTwitter implements ShareAdapter { +public class SocialTwitter implements InterfaceSocial { private static final String LOG_TAG = "SocialTwitter"; private static Activity mContext = null; - private static ShareAdapter mSocialAdapter = null; + private static InterfaceSocial mSocialAdapter = null; protected static boolean bDebug = false; private static String CONSUMER_KEY=""; private static String CONSUMER_SECRET=""; @@ -98,12 +97,12 @@ public class SocialTwitter implements ShareAdapter { LogD("share invoked " + info.toString()); mShareInfo = info; if (! networkReachable()) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "Network error!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "Network error!"); return; } if (! isInitialized) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "Initialize failed!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "Initialize failed!"); return; } @@ -153,7 +152,7 @@ public class SocialTwitter implements ShareAdapter { } private static void shareResult(int ret, String msg) { - InterfaceSocial.onShareResult(mSocialAdapter, ret, msg); + SocialWrapper.onShareResult(mSocialAdapter, ret, msg); LogD("SocialTwitter result : " + ret + " msg : " + msg); } @@ -162,7 +161,7 @@ public class SocialTwitter implements ShareAdapter { @Override public void onError(int flag, String value) { LogD("Twitter connection failed!"); - shareResult(InterfaceSocial.SHARERESULT_FAIL, value); + shareResult(SocialWrapper.SHARERESULT_FAIL, value); } @Override @@ -181,11 +180,16 @@ public class SocialTwitter implements ShareAdapter { mTwitter.updateStatus(text); } LogD("Posted to Twitter!"); - shareResult(InterfaceSocial.SHARERESULT_SUCCESS, "Share succeed!"); + shareResult(SocialWrapper.SHARERESULT_SUCCESS, "Share succeed!"); } catch (Exception e) { LogD("Post to Twitter failed!"); - shareResult(InterfaceSocial.SHARERESULT_FAIL, "Unknown error!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "Unknown error!"); e.printStackTrace(); } } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/umeng/include/AnalyticsUmeng.h b/plugin/plugins/umeng/include/AnalyticsUmeng.h deleted file mode 100644 index 187fb2c619..0000000000 --- a/plugin/plugins/umeng/include/AnalyticsUmeng.h +++ /dev/null @@ -1,189 +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. -****************************************************************************/ -#ifndef __CCX_ANALYTICS_UMENG_H__ -#define __CCX_ANALYTICS_UMENG_H__ - -#include "ProtocolAnalytics.h" - -namespace cocos2d { namespace plugin { - -// Please refer to http://dev.umeng.com/doc/document_ana_android.html for the detail informations about -// how to use the interfaces of Umeng. - -class AnalyticsUmeng : public ProtocolAnalytics -{ - PLUGIN_REGISTER_DECL(AnalyticsUmeng) -public: - enum UmengReportPolicy - { - REALTIME = 0, - BATCH_AT_LAUNCH = 1, - DAILY = 4, - WIFIONLY = 5 - }; - - virtual ~AnalyticsUmeng(); - - /** - @par override interface of base class - */ - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief Start a new session. - @param appKey The identity of the application. - */ - virtual void startSession(const char* appKey); - - /** - @brief Stop a session. - @warning This interface only worked on android - */ - virtual void stopSession(); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - @note It must be invoked before calling startSession. - */ - virtual void setDebugMode(bool debug); - - /** - @brief Set the timeout for expiring a session. - @param millis In milliseconds as the unit of time. - @note It must be invoked before calling startSession. - @warning Only worked on android - */ - virtual void setSessionContinueMillis(long millis); - - /** - @brief log an error - @param errorId The identity of error - @param message Extern message for the error - @warning Only worked on android - */ - virtual void logError(const char* errorId, const char* message); - - /** - @brief log an event. - @param eventId The identity of event - @param paramMap Extern parameters of the event, use NULL if not needed. - */ - virtual void logEvent(const char* eventId, LogEventParamMap* paramMap = NULL); - - /** - @brief Track an event begin. - @param eventId The identity of event - */ - virtual void logTimedEventBegin(const char* eventId); - - /** - @brief Track an event end. - @param eventId The identity of event - */ - virtual void logTimedEventEnd(const char* eventId); - - /** - @brief Whether to catch uncaught exceptions to server. - @warning This interface only worked on android. - */ - virtual void setCaptureUncaughtException(bool enabled); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - /** - @par Unique interface of Umeng - */ - - /** - @brief Update the online configuration - */ - void updateOnlineConfig(); - - /** - @brief Get the online configuration parameters - */ - const char* getConfigParams(const char* key); - - /** - @brief Set the default policy - */ - void setDefaultReportPolicy(UmengReportPolicy policy); - - /** - @brief Log event with a label. - * @note The label param is for distinguish event that with the same id. It will not be kept in the server. - */ - void logEventWithLabel(const char* eventId, const char* label); - - /** - @brief Log event with duration and a label - * @note The label param is for distinguish event that with the same id. It will not be kept in the server. - */ - void logEventWithDuration(const char* eventId, long duration, const char* label); - - /** - @brief Log event with duration and a map which contains event parameters. - * @note The label param is for distinguish event that with the same id. It will not be kept in the server. - */ - void logEventWithDuration(const char* eventId, long duration, LogEventParamMap* paramMap = NULL); - - /** - @brief Start log a timed event with a label. - */ - void logTimedEventWithLabelBegin(const char* eventId, const char* label); - - /** - @brief Finish log a timed event with a label - */ - void logTimedEventWithLabelEnd(const char* eventId, const char* label); - - /** - @brief Start log a timed event with a label and a map which contains event parameters. - */ - void logTimedKVEventBegin(const char* eventId, const char* label, LogEventParamMap* paramMap); - - /** - @brief Finish log a timed event with a label. - */ - void logTimedKVEventEnd(const char* eventId, const char* label); - - /** - @par interface for ios - */ - /** - @brief start session with policy and channel id - @warning On android, policy & channelId are ignored. - */ - void startSession(const char* appKey, UmengReportPolicy policy, const char* channelId); - void checkUpdate(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_ANALYTICS_UMENG_H__ */ diff --git a/plugin/plugins/umeng/jsb_umeng.ini b/plugin/plugins/umeng/jsb_umeng.ini deleted file mode 100644 index 0de2e13de9..0000000000 --- a/plugin/plugins/umeng/jsb_umeng.ini +++ /dev/null @@ -1,59 +0,0 @@ -[umeng] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_umeng - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/umeng/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/umeng/include/AnalyticsUmeng.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = AnalyticsUmeng - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = AnalyticsUmeng - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes diff --git a/plugin/plugins/umeng/platform/android/AnalyticsUmeng.cpp b/plugin/plugins/umeng/platform/android/AnalyticsUmeng.cpp deleted file mode 100644 index 42661f095f..0000000000 --- a/plugin/plugins/umeng/platform/android/AnalyticsUmeng.cpp +++ /dev/null @@ -1,354 +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. -****************************************************************************/ -#include "AnalyticsUmeng.h" -#include "PluginJniHelper.h" -#include -#include "PluginUtils.h" -#include "PluginJavaData.h" -#if 1 -#define LOG_TAG "AnalyticsUmeng" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(AnalyticsUmeng) - -AnalyticsUmeng::~AnalyticsUmeng() -{ - LOGD("AnalyticsUmeng destructor"); -} - -bool AnalyticsUmeng::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.AnalyticsUmeng"); -} - -void AnalyticsUmeng::updateOnlineConfig() -{ - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - LOGD("update online 01"); - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "updateOnlineConfig" - , "()V")) - { - LOGD("update online 02"); - t.env->CallVoidMethod(pData->jobj, t.methodID); - LOGD("update online 03"); - t.env->DeleteLocalRef(t.classID); - LOGD("update online 04"); - } -} - -const char* AnalyticsUmeng::getConfigParams(const char* key) -{ - static std::string ret = ""; - return_val_if_fails(key != NULL && strlen(key) > 0, ""); - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "getConfigParams" - , "(Ljava/lang/String;)Ljava/lang/String;")) - { - jstring jstrKey = t.env->NewStringUTF(key); - jstring jstr = (jstring)t.env->CallObjectMethod(pData->jobj, t.methodID, jstrKey); - ret = PluginJniHelper::jstring2string(jstr); - LOGD("ret = %s", ret.c_str()); - t.env->DeleteLocalRef(jstrKey); - t.env->DeleteLocalRef(t.classID); - } - return ret.c_str(); -} - -void AnalyticsUmeng::setDefaultReportPolicy(UmengReportPolicy ePolicy) -{ - return_if_fails(ePolicy == REALTIME - || ePolicy == BATCH_AT_LAUNCH - || ePolicy == DAILY - || ePolicy == WIFIONLY ); - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - LOGD("data : %p", pData); - LOGD("class name : %s", pData->jclassName.c_str()); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "setDefaultReportPolicy" - , "(I)V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, (jint)ePolicy); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logEventWithLabel(const char* eventId, const char* label) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logEventWithLabel" - , "(Ljava/lang/String;Ljava/lang/String;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jlabel); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, const char* label) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logEventWithDuration" - , "(Ljava/lang/String;ILjava/lang/String;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, duration, jlabel); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, LogEventParamMap* paramMap /* = NULL */) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (paramMap == NULL) - { - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logEventWithDuration" - , "(Ljava/lang/String;I)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, duration); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(t.classID); - } - } - else - { - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logEventWithDuration" - , "(Ljava/lang/String;ILjava/util/Hashtable;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jobject jparamMap= PluginUtils::createJavaMapObject(t, paramMap); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, duration, jparamMap); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jparamMap); - t.env->DeleteLocalRef(t.classID); - } - } - -} - -void AnalyticsUmeng::logTimedEventWithLabelBegin(const char* eventId, const char* label) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logTimedEventWithLabelBegin" - , "(Ljava/lang/String;Ljava/lang/String;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jlabel); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logTimedEventWithLabelEnd(const char* eventId, const char* label) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logTimedEventWithLabelEnd" - , "(Ljava/lang/String;Ljava/lang/String;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jlabel); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logTimedKVEventBegin(const char* eventId, const char* label, LogEventParamMap* paramMap) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logTimedKVEventBegin" - , "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Hashtable;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - jobject jparamMap= PluginUtils::createJavaMapObject(t, paramMap); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jlabel, jparamMap); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(jparamMap); - t.env->DeleteLocalRef(t.classID); - } -} - -void AnalyticsUmeng::logTimedKVEventEnd(const char* eventId, const char* label) -{ - return_if_fails(eventId != NULL && strlen(eventId) > 0); - return_if_fails(label != NULL && strlen(label) > 0); - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "logTimedKVEventEnd" - , "(Ljava/lang/String;Ljava/lang/String;)V")) - { - jstring jeventId = t.env->NewStringUTF(eventId); - jstring jlabel = t.env->NewStringUTF(label); - t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, jlabel); - t.env->DeleteLocalRef(jeventId); - t.env->DeleteLocalRef(jlabel); - t.env->DeleteLocalRef(t.classID); - } -} - -/** interface for ios */ -void AnalyticsUmeng::startSession(const char* appKey, UmengReportPolicy policy, const char* channelId) -{ - startSession(appKey); -} - -void AnalyticsUmeng::checkUpdate() -{ - -} - -/** override methods of base class */ -/** Start a new session. */ -void AnalyticsUmeng::startSession(const char* appKey) -{ - ProtocolAnalytics::startSession(appKey); -} - -/** Stop a session. */ -void AnalyticsUmeng::stopSession() -{ - ProtocolAnalytics::stopSession(); -} - -/** Set the timeout for expiring a session. */ -void AnalyticsUmeng::setSessionContinueMillis(long millis) -{ - ProtocolAnalytics::setSessionContinueMillis(millis); -} - -/** Whether to catch uncaught exceptions to server.*/ -void AnalyticsUmeng::setCaptureUncaughtException(bool enabled) -{ - ProtocolAnalytics::setCaptureUncaughtException(enabled); -} - -const char* AnalyticsUmeng::getSDKVersion() -{ - return ProtocolAnalytics::getSDKVersion(); -} - -/** Set whether needs to output logs to console.*/ -void AnalyticsUmeng::setDebugMode(bool debug) -{ - ProtocolAnalytics::setDebugMode(debug); -} - -/** log an error */ -void AnalyticsUmeng::logError(const char* errorId, const char* message) -{ - ProtocolAnalytics::logError(errorId, message); -} - -/** log an event. */ -void AnalyticsUmeng::logEvent(const char* eventId, LogEventParamMap* paramMap) -{ - ProtocolAnalytics::logEvent(eventId, paramMap); -} - -/** begin to log a timed event */ -void AnalyticsUmeng::logTimedEventBegin(const char* eventId) -{ - ProtocolAnalytics::logTimedEventBegin(eventId); -} - -/** end a timed event */ -void AnalyticsUmeng::logTimedEventEnd(const char* eventId) -{ - ProtocolAnalytics::logTimedEventEnd(eventId); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/umeng/platform/ios/AnalyticsUmeng.mm b/plugin/plugins/umeng/platform/ios/AnalyticsUmeng.mm deleted file mode 100644 index e4cd9d3ba4..0000000000 --- a/plugin/plugins/umeng/platform/ios/AnalyticsUmeng.mm +++ /dev/null @@ -1,380 +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. -****************************************************************************/ -#include "AnalyticsUmeng.h" -#include "MobClick.h" -#include "PluginUtilsIOS.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(AnalyticsUmeng) - -#define LOG_MAX_LENGTH (16 * 1024) - -static bool s_bDebugable = false; -void UmengLogD(const char * pszFormat, ...) { - if (s_bDebugable) { - printf("AnalyticsUmeng : "); - char szBuf[LOG_MAX_LENGTH]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf(szBuf, LOG_MAX_LENGTH, pszFormat, ap); - va_end(ap); - printf("%s", szBuf); - printf("\n"); - } -} - -AnalyticsUmeng::~AnalyticsUmeng() -{ -} - -bool AnalyticsUmeng::init() -{ - return PluginUtilsIOS::initOCPlugin(this, "UmengWrapper"); -} - -/** Start a new session. */ -void AnalyticsUmeng::startSession(const char* appKey) -{ - ProtocolAnalytics::startSession(appKey); -} - -/** Stop a session. only worked on android */ -void AnalyticsUmeng::stopSession() -{ - ProtocolAnalytics::stopSession(); -} - -/** Set whether needs to output logs to console.*/ -void AnalyticsUmeng::setDebugMode(bool debug) -{ - s_bDebugable = debug; - ProtocolAnalytics::setDebugMode(debug); -} - -/** Set the timeout for expiring a session. */ -void AnalyticsUmeng::setSessionContinueMillis(long millis) -{ - ProtocolAnalytics::setSessionContinueMillis(millis); -} - -/** log an error */ -void AnalyticsUmeng::logError(const char* errorId, const char* message) -{ - ProtocolAnalytics::logError(errorId, message); -} - -/** log an event. */ -void AnalyticsUmeng::logEvent(const char* eventId, LogEventParamMap* paramMap) -{ - ProtocolAnalytics::logEvent(eventId, paramMap); -} - -/** begin to log a timed event */ -void AnalyticsUmeng::logTimedEventBegin(const char* eventId) -{ - ProtocolAnalytics::logTimedEventBegin(eventId); -} - -/** end a timed event */ -void AnalyticsUmeng::logTimedEventEnd(const char* eventId) -{ - ProtocolAnalytics::logTimedEventEnd(eventId); -} - -/** Whether to catch uncaught exceptions to server.*/ -void AnalyticsUmeng::setCaptureUncaughtException(bool enabled) -{ - ProtocolAnalytics::setCaptureUncaughtException(enabled); -} - -const char* AnalyticsUmeng::getSDKVersion() -{ - return ProtocolAnalytics::getSDKVersion(); -} - -void AnalyticsUmeng::updateOnlineConfig() -{ - PluginUtilsIOS::callOCFunctionWithName(this, "updateOnlineConfig"); -} - -const char* AnalyticsUmeng::getConfigParams(const char* key) -{ - NSString* strKey = [NSString stringWithUTF8String:key]; - return [[MobClick getConfigParams:strKey] UTF8String]; - - - if (NULL == key || strlen(key) == 0) { - UmengLogD("The key is invalid!"); - return ""; - } - - NSString* pKey = [NSString stringWithUTF8String:key]; - NSString* ret = nil; - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"getConfigParams:"); - if ([pOCObj respondsToSelector:selector]) { - ret = [pOCObj performSelector:selector withObject:pKey]; - } - } - - const char* pRet = (nil == ret) ? NULL : [ret UTF8String]; - return pRet; -} - -static AnalyticsUmeng::UmengReportPolicy s_defaultPolicy = AnalyticsUmeng::UmengReportPolicy::REALTIME; -void AnalyticsUmeng::setDefaultReportPolicy(UmengReportPolicy ePolicy) -{ - s_defaultPolicy = ePolicy; -} - -void AnalyticsUmeng::logEventWithLabel(const char* eventId, const char* label) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - NSString* strEvent = [NSString stringWithUTF8String:eventId]; - NSString* strLabel = [NSString stringWithUTF8String:label]; - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logEvent:withLabel:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:strEvent withObject:strLabel]; - } - } -} - -void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, const char* label) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - do { - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - - if (! pData) break; - - id pOCObj = pData->obj; - NSString* className = [NSString stringWithUTF8String:pData->className.c_str()]; - SEL selector = NSSelectorFromString(@"logEvent:withDuration:withLabel:"); - - if (! [pOCObj respondsToSelector:selector]) { - break; - } - - NSString* strEventId = [NSString stringWithUTF8String:eventId]; - NSString* strLabel = [NSString stringWithUTF8String:label]; - NSNumber* numDur = [NSNumber numberWithLong:duration]; - - NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector]; - NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig]; - [invocation setTarget:pOCObj]; - [invocation setSelector:selector]; - [invocation setArgument:&strEventId atIndex:2]; - [invocation setArgument:&numDur atIndex:3]; - [invocation setArgument:&strLabel atIndex:4]; - [invocation retainArguments]; - [invocation invoke]; - } while (0); -} - -void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, LogEventParamMap* paramMap) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - do { - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - - if (! pData) break; - - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logEvent:withDuration:withParam:"); - - if (! [pOCObj respondsToSelector:selector]) { - break; - } - - NSString* strEventId = [NSString stringWithUTF8String:eventId]; - NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); - NSNumber* numDur = [NSNumber numberWithLong:duration]; - - NSMethodSignature *sig = [[pOCObj class] instanceMethodSignatureForSelector:selector]; - NSInvocation *invocation =[NSInvocation invocationWithMethodSignature:sig]; - - [invocation setSelector:selector]; - [invocation setTarget:pOCObj]; - [invocation setArgument:&strEventId atIndex:2]; - [invocation setArgument:&numDur atIndex:3]; - [invocation setArgument:&dict atIndex:4]; - [invocation retainArguments]; - [invocation invoke]; - } while (0); -} - -void AnalyticsUmeng::logTimedEventWithLabelBegin(const char* eventId, const char* label) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - NSString* strEvent = [NSString stringWithUTF8String:eventId]; - NSString* strLabel = [NSString stringWithUTF8String:label]; - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logTimedEventBegin:withLabel:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:strEvent withObject:strLabel]; - } - } -} - -void AnalyticsUmeng::logTimedEventWithLabelEnd(const char* eventId, const char* label) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - NSString* strEvent = [NSString stringWithUTF8String:eventId]; - NSString* strLabel = [NSString stringWithUTF8String:label]; - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logTimedEventEnd:withLabel:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:strEvent withObject:strLabel]; - } - } -} - -void AnalyticsUmeng::logTimedKVEventBegin(const char* eventId, const char* label, LogEventParamMap* paramMap) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - do { - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - - if (! pData) break; - - id pOCObj = pData->obj; - NSString* className = [NSString stringWithUTF8String:pData->className.c_str()]; - SEL selector = NSSelectorFromString(@"logTimedKVEventBegin:withLabel:withParam:"); - - if (! [pOCObj respondsToSelector:selector]) { - break; - } - - NSString* strEventId = [NSString stringWithUTF8String:eventId]; - NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); - NSString* strLabel = [NSString stringWithUTF8String:label]; - - NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector]; - NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig]; - [invocation setTarget:pOCObj]; - [invocation setSelector:selector]; - [invocation setArgument:&strEventId atIndex:2]; - [invocation setArgument:&strLabel atIndex:3]; - [invocation setArgument:&dict atIndex:4]; - [invocation retainArguments]; - [invocation invoke]; - } while (0); -} - -void AnalyticsUmeng::logTimedKVEventEnd(const char* eventId, const char* label) -{ - if (NULL == eventId || strlen(eventId) == 0) { - UmengLogD("eventId is invalid"); - return; - } - - NSString* strEvent = [NSString stringWithUTF8String:eventId]; - NSString* strLabel = [NSString stringWithUTF8String:label]; - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (pData) { - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logTimedKVEventEnd:withLabel:"); - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:strEvent withObject:strLabel]; - } - } -} - -void AnalyticsUmeng::startSession(const char* appKey, UmengReportPolicy policy, const char* channelId) -{ - if (NULL == appKey || strlen(appKey) == 0) { - UmengLogD("appKey is invalid"); - return; - } - - do { - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - - if (! pData) break; - - id pOCObj = pData->obj; - NSString* className = [NSString stringWithUTF8String:pData->className.c_str()]; - SEL selector = NSSelectorFromString(@"logTimedKVEventBegin:withLabel:withParam:"); - - if (! [pOCObj respondsToSelector:selector]) { - break; - } - - NSString* strKey = [NSString stringWithUTF8String:appKey]; - NSNumber* numPolicy = [NSNumber numberWithInt:policy]; - NSString* strChannel = [NSString stringWithUTF8String:channelId]; - - NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector]; - NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig]; - [invocation setTarget:pOCObj]; - [invocation setSelector:selector]; - [invocation setArgument:&strKey atIndex:2]; - [invocation setArgument:&numPolicy atIndex:3]; - [invocation setArgument:&strChannel atIndex:4]; - [invocation retainArguments]; - [invocation invoke]; - } while (0); -} - -void AnalyticsUmeng::checkUpdate() -{ - PluginUtilsIOS::callOCFunctionWithName(this, "checkUpdate"); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/umeng/platform/ios/UmengWrapper.h b/plugin/plugins/umeng/platform/ios/UmengWrapper.h deleted file mode 100644 index e44671079d..0000000000 --- a/plugin/plugins/umeng/platform/ios/UmengWrapper.h +++ /dev/null @@ -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 UmengWrapper : NSObject -{ - -} - -/** - interfaces of protocol : InterfaceAnalytics - */ -- (void) startSession: (NSString*) appKey; -- (void) stopSession; -- (void) setSessionContinueMillis: (NSNumber*) millis; -- (void) setCaptureUncaughtException: (NSNumber*) isEnabled; -- (void) setDebugMode: (NSNumber*) 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; - -/** - interfaces of umeng SDK - */ -- (void) updateOnlineConfig; -- (NSString*) getConfigParams: (NSString*) key; -- (void) logEvent: (NSString*) eventId withLabel:(NSString*) label; -- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withLabel:(NSString*) label; -- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withParam:(NSMutableDictionary*) paramMap; -- (void) logTimedEventBegin: (NSString*) eventId withLabel:(NSString*) label; -- (void) logTimedEventEnd: (NSString*) eventId withLabel:(NSString*) label; -- (void) logTimedKVEventBegin: (NSString*) eventId withLabel:(NSString*) label withParam:(NSMutableDictionary*) paramMap; -- (void) logTimedKVEventEnd: (NSString*) eventId withLabel:(NSString*) label; -- (void) startSession: (NSString*) appKey withPolicy:(NSNumber*) policy withChannel:(NSString*) channelId; -- (void) checkUpdate; - -@end diff --git a/plugin/plugins/umeng/platform/ios/UmengWrapper.m b/plugin/plugins/umeng/platform/ios/UmengWrapper.m deleted file mode 100644 index d01990a15f..0000000000 --- a/plugin/plugins/umeng/platform/ios/UmengWrapper.m +++ /dev/null @@ -1,170 +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 "UmengWrapper.h" -#import "MobClick.h" - -@implementation UmengWrapper - -- (void) startSession: (NSString*) appKey -{ - [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"]; - [MobClick startWithAppkey:appKey]; -} - -- (void) stopSession -{ - NSLog(@"stopSession in umeng not available on iOS"); -} - -- (void) setSessionContinueMillis: (NSNumber*) millis -{ - NSLog(@"setSessionContinueMillis in umeng not available on iOS"); -} - -- (void) setCaptureUncaughtException: (NSNumber*) isEnabled -{ - BOOL bEnabled = [isEnabled boolValue]; - [MobClick setCrashReportEnabled:bEnabled]; -} - -- (void) setDebugMode: (NSNumber*) isDebugMode -{ - BOOL bDebug = [isDebugMode boolValue]; - [MobClick setLogEnabled:bDebug]; -} - -- (void) logError: (NSString*) errorId withMsg:(NSString*) message -{ - NSLog(@"logError in umeng not available on iOS"); -} - -- (void) logEvent: (NSString*) eventId -{ - [MobClick event:eventId]; -} - -- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap -{ - [MobClick event:eventId attributes:paramMap]; -} - -- (void) logTimedEventBegin: (NSString*) eventId -{ - [MobClick beginEvent:eventId]; -} - -- (void) logTimedEventEnd: (NSString*) eventId -{ - [MobClick endEvent:eventId]; -} - -- (NSString*) getSDKVersion -{ - return @"UMeng no version info"; -} - -- (void) updateOnlineConfig -{ - [MobClick updateOnlineConfig]; -} - -- (NSString*) getConfigParams: (NSString*) key -{ - return [MobClick getConfigParams:key]; -} - -- (void) logEvent: (NSString*) eventId withLabel:(NSString*) label -{ - [MobClick event:eventId label:label]; -} - -- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withLabel:(NSString*) label -{ - long numDur = [duration longValue]; - if (! label) { - [MobClick event:eventId durations:numDur]; - } else { - [MobClick event:eventId label:label durations:numDur]; - } -} - -- (void) logEvent: (NSString*) eventId withDuration:(NSNumber*) duration withParam:(NSMutableDictionary*) paramMap -{ - long numDur = [duration longValue]; - if (! paramMap) { - [MobClick event:eventId durations:(int)numDur]; - } else { - [MobClick event:eventId attributes:paramMap durations:(int)numDur]; - } -} - -- (void) logTimedEventBegin: (NSString*) eventId withLabel:(NSString*) label -{ - if (! label) { - [MobClick beginEvent:eventId]; - } else { - [MobClick beginEvent:eventId label:label]; - } -} - -- (void) logTimedEventEnd: (NSString*) eventId withLabel:(NSString*) label -{ - if (! label) { - [MobClick endEvent:eventId]; - } else { - [MobClick endEvent:eventId label:label]; - } -} - -- (void) logTimedKVEventBegin: (NSString*) eventId withLabel:(NSString*) label withParam:(NSMutableDictionary*) paramMap -{ - if (! label || ! paramMap) { - [MobClick beginEvent:eventId]; - } else { - [MobClick beginEvent:eventId primarykey:label attributes:paramMap]; - } -} - -- (void) logTimedKVEventEnd: (NSString*) eventId withLabel:(NSString*) label -{ - if (! label) { - [MobClick endEvent:eventId]; - } else { - [MobClick endEvent:eventId primarykey:label]; - } -} - -- (void) startSession: (NSString*) appKey withPolicy:(NSNumber*) policy withChannel:(NSString*) channelId -{ - int nPolicy = [policy intValue]; - [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"]; - [MobClick startWithAppkey:appKey reportPolicy:(ReportPolicy)nPolicy channelId:channelId]; -} - -- (void) checkUpdate -{ - [MobClick checkUpdate]; -} - -@end diff --git a/plugin/plugins/umeng/proj.android/.project b/plugin/plugins/umeng/proj.android/.project index 40d433d922..21bd34bcab 100644 --- a/plugin/plugins/umeng/proj.android/.project +++ b/plugin/plugins/umeng/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/umeng/proj.android/build_native.sh b/plugin/plugins/umeng/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/umeng/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/umeng/proj.android/jni/Android.mk b/plugin/plugins/umeng/proj.android/jni/Android.mk deleted file mode 100644 index d63ee1a0e5..0000000000 --- a/plugin/plugins/umeng/proj.android/jni/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginUmengStatic - -LOCAL_MODULE_FILENAME := libPluginUmengStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - AnalyticsUmeng.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) - diff --git a/plugin/plugins/umeng/proj.android/jni/Application.mk b/plugin/plugins/umeng/proj.android/jni/Application.mk deleted file mode 100644 index 3b6a51c3fd..0000000000 --- a/plugin/plugins/umeng/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginUmengStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/umeng/proj.android/src/org/cocos2dx/plugin/AnalyticsUmeng.java b/plugin/plugins/umeng/proj.android/src/org/cocos2dx/plugin/AnalyticsUmeng.java index 278d9e2c6b..108e2bedcc 100644 --- a/plugin/plugins/umeng/proj.android/src/org/cocos2dx/plugin/AnalyticsUmeng.java +++ b/plugin/plugins/umeng/proj.android/src/org/cocos2dx/plugin/AnalyticsUmeng.java @@ -27,229 +27,274 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; +import org.json.JSONObject; + import android.content.Context; import android.util.Log; import com.umeng.analytics.MobclickAgent; public class AnalyticsUmeng implements InterfaceAnalytics{ - - private Context mContext = null; - - protected static String TAG = "AnalyticsUmeng"; - - protected static void LogE(String msg, Exception e) { - Log.e(TAG, msg, e); - e.printStackTrace(); - } + + private Context mContext = null; + + protected static String TAG = "AnalyticsUmeng"; - private static boolean isDebug = true; - protected static void LogD(String msg) { - if (isDebug) { - Log.d(TAG, msg); - } - } + protected static void LogE(String msg, Exception e) { + Log.e(TAG, msg, e); + e.printStackTrace(); + } - public AnalyticsUmeng(Context context) { - mContext = context; - MobclickAgent.setWrapper("Cocos2d-x", "1.0"); - } - - public boolean isValid() { - return mContext != null; - } - @Override - public void startSession(String appKey) { - LogD("startSession invoked!"); - MobclickAgent.onResume(mContext); - } + private static boolean isDebug = true; + protected static void LogD(String msg) { + if (isDebug) { + Log.d(TAG, msg); + } + } - @Override - public void stopSession() { - LogD("stopSession invoked!"); - MobclickAgent.onPause(mContext); - } + public AnalyticsUmeng(Context context) { + mContext = context; + MobclickAgent.setWrapper("Cocos2d-x", "1.0"); + } + + public boolean isValid() { + return mContext != null; + } + @Override + public void startSession(String appKey) { + LogD("startSession invoked!"); + MobclickAgent.onResume(mContext); + } - @Override - public void setSessionContinueMillis(int millis) { - LogD("setSessionContinueMillis invoked!"); - MobclickAgent.setSessionContinueMillis(millis); - } + @Override + public void stopSession() { + LogD("stopSession invoked!"); + MobclickAgent.onPause(mContext); + } - @Override - public void setCaptureUncaughtException(boolean isEnabled) { - LogD("setCaptureUncaughtException invoked!"); - if (isEnabled) { - MobclickAgent.onError(mContext); - } - } + @Override + public void setSessionContinueMillis(int millis) { + LogD("setSessionContinueMillis invoked!"); + MobclickAgent.setSessionContinueMillis(millis); + } - @Override - public void setDebugMode(boolean isDebugMode) { - isDebug = isDebugMode; - MobclickAgent.setDebugMode(isDebugMode); - } + @Override + public void setCaptureUncaughtException(boolean isEnabled) { + LogD("setCaptureUncaughtException invoked!"); + if (isEnabled) { + MobclickAgent.onError(mContext); + } + } - @Override - public void logError(String errorId, String message) { - LogD("logError invoked!"); - MobclickAgent.reportError(mContext, message); - } + @Override + public void setDebugMode(boolean isDebugMode) { + isDebug = isDebugMode; + MobclickAgent.setDebugMode(isDebugMode); + } - @Override - public void logEvent(String eventId) { - LogD("logEvent(eventId) invoked!"); - MobclickAgent.onEvent(mContext, eventId); - } + @Override + public void logError(String errorId, String message) { + LogD("logError invoked!"); + MobclickAgent.reportError(mContext, message); + } - @Override - public void logEvent(String eventId, Hashtable paramMap) { - LogD("logEvent(eventId, paramMap) invoked!"); - HashMap curParam = changeTableToMap(paramMap); - MobclickAgent.onEvent(mContext, eventId, curParam); - } + @Override + public void logEvent(String eventId) { + LogD("logEvent(eventId) invoked!"); + MobclickAgent.onEvent(mContext, eventId); + } - @Override - public void logTimedEventBegin(String eventId) { - LogD("logTimedEventBegin invoked!"); - MobclickAgent.onEventBegin(mContext, eventId); - } + @Override + public void logEvent(String eventId, Hashtable paramMap) { + LogD("logEvent(eventId, paramMap) invoked!"); + HashMap curParam = changeTableToMap(paramMap); + MobclickAgent.onEvent(mContext, eventId, curParam); + } - @Override - public void logTimedEventEnd(String eventId) { - LogD("logTimedEventEnd invoked!"); - MobclickAgent.onEventEnd(mContext, eventId); - } + @Override + public void logTimedEventBegin(String eventId) { + LogD("logTimedEventBegin invoked!"); + MobclickAgent.onEventBegin(mContext, eventId); + } - @Override - public String getSDKVersion() { - LogD("getSDKVersion invoked!"); - return "UMeng no version info"; - } + @Override + public void logTimedEventEnd(String eventId) { + LogD("logTimedEventEnd invoked!"); + MobclickAgent.onEventEnd(mContext, eventId); + } - protected String getConfigParams(String key) { - LogD("getConfigParams invoked!"); - if (!isValid()) return null; - String ret = ""; - try{ - ret = MobclickAgent.getConfigParams(mContext, key); - } catch(Exception e){ - LogE("Exception in logTimedEventBegin", e); - } - return ret; - } - - protected void updateOnlineConfig() { - LogD("updateOnlineConfig invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.updateOnlineConfig(mContext); - } catch(Exception e){ - LogE("Exception in updateOnlineConfig", e); - } - } - - protected void setDefaultReportPolicy(int policy) { - LogD("setDefaultReportPolicy invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.setDefaultReportPolicy(mContext, policy); - } catch(Exception e){ - LogE("Exception in setDefaultReportPolicy", e); - } - } - - protected void logEventWithLabel(String eventId, String label) { - LogD("logEventWithLabel invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onEvent(mContext, eventId, label); - } catch(Exception e){ - LogE("Exception in logEventWithLabel", e); - } - } - - protected void logEventWithDuration(String eventId, int duration) { - LogD("logEventWithDuration(eventId, duration) invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onEventDuration(mContext, eventId, duration); - } catch(Exception e){ - LogE("Exception in logEventWithDuration, eventId, duration", e); - } - } - - protected void logEventWithDuration(String eventId, int duration, String label) { - LogD("logEventWithDuration(eventId, duration, label) invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onEventDuration(mContext, eventId, label, duration); - } catch(Exception e){ - LogE("Exception in logEventWithDuration, eventId, label, duration", e); - } - } - - protected void logEventWithDuration(String eventId, int duration, Hashtable paramMap) { - LogD("logEventWithDuration(eventId, duration, paramMap) invoked!"); - if (!isValid()) return; - try{ - HashMap curMap = changeTableToMap(paramMap); - MobclickAgent.onEventDuration(mContext, eventId, curMap, duration); - } catch(Exception e){ - LogE("Exception in logEventWithDuration,eventId,duration,paramMap", e); - } - } - - protected void logTimedEventWithLabelBegin(String eventId, String label) { - LogD("logTimedEventWithLabelBegin invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onEventBegin(mContext, eventId, label); - } catch(Exception e){ - LogE("Exception in logTimedEventWithLabelBegin", e); - } - } - - protected void logTimedEventWithLabelEnd(String eventId, String label) { - LogD("logTimedEventWithLabelEnd invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onEventEnd(mContext, eventId, label); - } catch(Exception e){ - LogE("Exception in logTimedEventWithLabelEnd", e); - } - } - - protected void logTimedKVEventBegin(String eventId, String label, Hashtable paramMap) { - LogD("logTimedKVEventBegin invoked!"); - if (!isValid()) return; - try{ - HashMap curMap = changeTableToMap(paramMap); - MobclickAgent.onKVEventBegin(mContext, eventId, curMap, label); - } catch(Exception e){ - LogE("Exception in logTimedKVEventBegin", e); - } - } - - protected void logTimedKVEventEnd(String eventId, String label) { - LogD("logTimedKVEventEnd invoked!"); - if (!isValid()) return; - try{ - MobclickAgent.onKVEventEnd(mContext, eventId, label); - } catch(Exception e){ - LogE("Exception in logTimedKVEventEnd", e); - } - } + @Override + public String getSDKVersion() { + LogD("getSDKVersion invoked!"); + return "UMeng no version info"; + } - private HashMap changeTableToMap(Hashtable param) { - HashMap retParam = new HashMap(); - for(Iterator it = param.keySet().iterator(); it.hasNext(); ) { + protected String getConfigParams(String key) { + LogD("getConfigParams(" + key + ") invoked!"); + if (!isValid()) return null; + String ret = ""; + try{ + ret = MobclickAgent.getConfigParams(mContext, key); + } catch(Exception e){ + LogE("Exception in logTimedEventBegin", e); + } + LogD("get config : " + ret); + return ret; + } + + protected void updateOnlineConfig() { + LogD("updateOnlineConfig invoked!"); + if (!isValid()) return; + try{ + MobclickAgent.updateOnlineConfig(mContext); + } catch(Exception e){ + LogE("Exception in updateOnlineConfig", e); + } + } + + protected void logEventWithLabel(JSONObject eventInfo) { + LogD("logEventWithLabel invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + String label = eventInfo.getString("Param2"); + MobclickAgent.onEvent(mContext, eventId, label); + } catch(Exception e){ + LogE("Exception in logEventWithLabel", e); + } + } + + protected void logEventWithDurationLabel(JSONObject eventInfo) { + LogD("logEventWithDurationLabel invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try { + String eventId = eventInfo.getString("Param1"); + int duration = eventInfo.getInt("Param2"); + if (eventInfo.has("Param3")) { + String label = eventInfo.getString("Param3"); + MobclickAgent.onEventDuration(mContext, eventId, label, duration); + } else { + MobclickAgent.onEventDuration(mContext, eventId, duration); + } + } catch (Exception e) { + LogE("Exception in logEventWithDurationLabel", e); + } + } + + protected void logEventWithDurationParams(JSONObject eventInfo) { + LogD("logEventWithDurationParams invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try { + String eventId = eventInfo.getString("Param1"); + int duration = eventInfo.getInt("Param2"); + if (eventInfo.has("Param3")) { + JSONObject params = eventInfo.getJSONObject("Param3"); + HashMap curMap = getMapFromJson(params); + MobclickAgent.onEventDuration(mContext, eventId, curMap, duration); + } else { + MobclickAgent.onEventDuration(mContext, eventId, duration); + } + } catch (Exception e) { + LogE("Exception in logEventWithDurationParams", e); + } + } + + protected void logEventWithDuration(JSONObject eventInfo) { + LogD("logEventWithDuration invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + int duration = eventInfo.getInt("Param2"); + MobclickAgent.onEventDuration(mContext, eventId, duration); + } catch(Exception e){ + LogE("Exception in logEventWithDuration", e); + } + } + + protected void logTimedEventWithLabelBegin(JSONObject eventInfo) { + LogD("logTimedEventWithLabelBegin invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + String label = eventInfo.getString("Param2"); + MobclickAgent.onEventBegin(mContext, eventId, label); + } catch(Exception e){ + LogE("Exception in logTimedEventWithLabelBegin", e); + } + } + + protected void logTimedEventWithLabelEnd(JSONObject eventInfo) { + LogD("logTimedEventWithLabelEnd invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + String label = eventInfo.getString("Param2"); + MobclickAgent.onEventEnd(mContext, eventId, label); + } catch(Exception e){ + LogE("Exception in logTimedEventWithLabelEnd", e); + } + } + + protected void logTimedKVEventBegin(JSONObject eventInfo) { + LogD("logTimedKVEventBegin invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + String label = eventInfo.getString("Param2"); + JSONObject params = eventInfo.getJSONObject("Param3"); + + if (params != null) { + HashMap curMap = getMapFromJson(params); + MobclickAgent.onKVEventBegin(mContext, eventId, curMap, label); + } + } catch(Exception e){ + LogE("Exception in logTimedKVEventBegin", e); + } + } + + protected void logTimedKVEventEnd(JSONObject eventInfo) { + LogD("logTimedKVEventEnd invoked! event : " + eventInfo.toString()); + if (!isValid()) return; + try{ + String eventId = eventInfo.getString("Param1"); + String label = eventInfo.getString("Param2"); + MobclickAgent.onKVEventEnd(mContext, eventId, label); + } catch(Exception e){ + LogE("Exception in logTimedKVEventEnd", e); + } + } + + private HashMap changeTableToMap(Hashtable param) { + HashMap retParam = new HashMap(); + for(Iterator it = param.keySet().iterator(); it.hasNext(); ) { String key = it.next(); String value = param.get(key); retParam.put(key, value); } - return retParam; - } + return retParam; + } + + private HashMap getMapFromJson(JSONObject json) { + HashMap curMap = new HashMap(); + try { + @SuppressWarnings("rawtypes") + Iterator it = json.keys(); + while (it.hasNext()) { + String key = (String) it.next(); + String value = json.getString(key); + curMap.put(key, value); + } + } catch (Exception e) { + LogE("Error when get HashMap from JSONObject", e); + } + + return curMap; + } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.h b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.h new file mode 100644 index 0000000000..5f4cfa1cf9 --- /dev/null +++ b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.h @@ -0,0 +1,131 @@ +/**************************************************************************** +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 AnalyticsUmeng : NSObject +{ +} + +@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 umeng SDK + */ +- (void) updateOnlineConfig; +- (NSString*) getConfigParams: (NSString*) key; + +/** + @brief logEvent with label. + @param params The dictionary include eventId & label + get eventId with key 'Param1' from dictionary + get label with key 'Param2' from dictionary + */ +- (void) logEventWithLabel: (NSMutableDictionary*) params; + +/** + @brief logEvent with duration. + @param params The dictionary include eventId & duration + get eventId with key 'Param1' from dictionary + get duration with key 'Param2' from dictionary + */ +- (void) logEventWithDuration: (NSMutableDictionary*) params; + +/** + @brief logEvent with duration & label. + @param params The dictionary include eventId & duration & label + get eventId with key 'Param1' from dictionary + get duration with key 'Param2' from dictionary + get label with key 'Param3' from dictionary + */ +- (void) logEventWithDurationLabel: (NSMutableDictionary*) params; + +/** + @brief logEvent with duration & attributes. + @param params The dictionary include eventId & duration & attributes + get eventId with key 'Param1' from dictionary + get duration with key 'Param2' from dictionary + get attributes with key 'Param3' from dictionary + */ +- (void) logEventWithDurationParams: (NSMutableDictionary*) params; + +/** + @brief log timed event begin with label. + @param params The dictionary include eventId & label + get eventId with key 'Param1' from dictionary + get label with key 'Param2' from dictionary + */ +- (void) logTimedEventWithLabelBegin: (NSMutableDictionary*) params; + +/** + @brief log timed event end with label. + @param params The dictionary include eventId & label + get eventId with key 'Param1' from dictionary + get label with key 'Param2' from dictionary + */ +- (void) logTimedEventWithLabelEnd: (NSMutableDictionary*) params; + +/** + @brief log timed KV event with label & attributes. + @param params The dictionary include eventId & label & attributes + get eventId with key 'Param1' from dictionary + get label with key 'Param2' from dictionary + get attributes with key 'Param3' from dictionary + */ +- (void) logTimedKVEventBegin: (NSMutableDictionary*) params; + +/** + @brief log timed KV event end with label. + @param params The dictionary include eventId & label + get eventId with key 'Param1' from dictionary + get label with key 'Param2' from dictionary + */ +- (void) logTimedKVEventEnd: (NSMutableDictionary*) params; + +/** + @brief start session with policy & channelId. + @param params The dictionary include appKey & policy & channelId + get appKey with key 'Param1' from dictionary + get policy(NSNumber*) with key 'Param2' from dictionary + get channelId with key 'Param3' from dictionary + */ +- (void) startSessionWithParams: (NSMutableDictionary*) params; +- (void) checkUpdate; + +@end diff --git a/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m new file mode 100644 index 0000000000..7805586e6b --- /dev/null +++ b/plugin/plugins/umeng/proj.ios/AnalyticsUmeng.m @@ -0,0 +1,236 @@ +/**************************************************************************** +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 "AnalyticsUmeng.h" +#import "MobClick.h" + +#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__); + +@implementation AnalyticsUmeng + +@synthesize debug = __debug; + +- (void) startSession: (NSString*) appKey +{ + OUTPUT_LOG(@"Umeng startSession invoked"); + [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"]; + [MobClick startWithAppkey:appKey]; +} + +- (void) stopSession +{ + OUTPUT_LOG(@"Umeng stopSession in umeng not available on iOS"); +} + +- (void) setSessionContinueMillis: (long) millis +{ + OUTPUT_LOG(@"Umeng setSessionContinueMillis in umeng not available on iOS"); +} + +- (void) setCaptureUncaughtException: (BOOL) isEnabled +{ + OUTPUT_LOG(@"Umeng setCaptureUncaughtException invoked"); + [MobClick setCrashReportEnabled:isEnabled]; +} + +- (void) setDebugMode: (BOOL) isDebugMode +{ + OUTPUT_LOG(@"Umeng setDebugMode invoked"); + self.debug = isDebugMode; + [MobClick setLogEnabled:isDebugMode]; +} + +- (void) logError: (NSString*) errorId withMsg:(NSString*) message +{ + OUTPUT_LOG(@"logError in umeng not available on iOS"); +} + +- (void) logEvent: (NSString*) eventId +{ + OUTPUT_LOG(@"Umeng logEvent invoked"); + [MobClick event:eventId]; +} + +- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap +{ + OUTPUT_LOG(@"Umeng logEventWithParam invoked"); + [MobClick event:eventId attributes:paramMap]; +} + +- (void) logTimedEventBegin: (NSString*) eventId +{ + OUTPUT_LOG(@"Umeng logTimedEventBegin invoked"); + [MobClick beginEvent:eventId]; +} + +- (void) logTimedEventEnd: (NSString*) eventId +{ + OUTPUT_LOG(@"Umeng logTimedEventEnd invoked"); + [MobClick endEvent:eventId]; +} + +- (NSString*) getSDKVersion +{ + return @"2.2.0"; +} + +- (NSString*) getPluginVersion +{ + return @"0.2.0"; +} + +- (void) updateOnlineConfig +{ + OUTPUT_LOG(@"Umeng updateOnlineConfig invoked"); + [MobClick updateOnlineConfig]; +} + +- (NSString*) getConfigParams: (NSString*) key +{ + OUTPUT_LOG(@"Umeng getConfigParams invoked (%@)", key); + return [MobClick getConfigParams:key]; +} + +- (void) logEventWithLabel: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logEventWithLabel invoked (%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSString* label = (NSString*) [params objectForKey:@"Param2"]; + if (label) { + [MobClick event:eventId label:label]; + } else { + [MobClick event:eventId]; + } +} + +- (void) logEventWithDuration: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logEventWithDuration invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"]; + long numDur = [duration longValue]; + [MobClick event:eventId durations:numDur]; +} + +- (void) logEventWithDurationLabel:(NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logEventWithDurationLabel invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"]; + NSString* label = (NSString*) [params objectForKey:@"Param3"]; + long numDur = [duration longValue]; + + if (! label) { + [MobClick event:eventId durations:numDur]; + } else { + [MobClick event:eventId label:label durations:numDur]; + } +} + +- (void) logEventWithDurationParams: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logEventWithDurationParams invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"]; + NSMutableDictionary* paramMap = (NSMutableDictionary*) [params objectForKey:@"Param3"]; + long numDur = [duration longValue]; + + if (! paramMap) { + [MobClick event:eventId durations:numDur]; + } else { + [MobClick event:eventId attributes:paramMap durations:numDur]; + } +} + +- (void) logTimedEventWithLabelBegin: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logTimedEventWithLabelBegin invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSString* label = (NSString*) [params objectForKey:@"Param2"]; + + if (! label) { + [MobClick beginEvent:eventId]; + } else { + [MobClick beginEvent:eventId label:label]; + } +} + +- (void) logTimedEventWithLabelEnd: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logTimedEventWithLabelEnd invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSString* label = (NSString*) [params objectForKey:@"Param2"]; + + if (! label) { + [MobClick endEvent:eventId]; + } else { + [MobClick endEvent:eventId label:label]; + } +} + +- (void) logTimedKVEventBegin: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logTimedKVEventBegin invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSString* label = (NSString*) [params objectForKey:@"Param2"]; + NSMutableDictionary* paramMap = (NSMutableDictionary*) [params objectForKey:@"Param3"]; + + if (! label || ! paramMap) { + [MobClick beginEvent:eventId]; + } else { + [MobClick beginEvent:eventId primarykey:label attributes:paramMap]; + } +} + +- (void) logTimedKVEventEnd: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng logTimedKVEventEnd invoked(%@)", [params debugDescription]); + NSString* eventId = (NSString*) [params objectForKey:@"Param1"]; + NSString* label = (NSString*) [params objectForKey:@"Param2"]; + + if (! label) { + [MobClick endEvent:eventId]; + } else { + [MobClick endEvent:eventId primarykey:label]; + } +} + +- (void) startSessionWithParams: (NSMutableDictionary*) params +{ + OUTPUT_LOG(@"Umeng startSessionWithParams invoked(%@)", [params debugDescription]); + NSString* appKey = (NSString*) [params objectForKey:@"Param1"]; + NSNumber* policy = (NSNumber*) [params objectForKey:@"Param2"]; + NSString* channelId = (NSString*) [params objectForKey:@"Param3"]; + + int nPolicy = [policy intValue]; + [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"]; + [MobClick startWithAppkey:appKey reportPolicy:(ReportPolicy)nPolicy channelId:channelId]; +} + +- (void) checkUpdate +{ + OUTPUT_LOG(@"Umeng checkUpdate invoked"); + [MobClick checkUpdate]; +} + +@end diff --git a/plugin/plugins/umeng/platform/ios/MobClick.h b/plugin/plugins/umeng/proj.ios/MobClick.h similarity index 100% rename from plugin/plugins/umeng/platform/ios/MobClick.h rename to plugin/plugins/umeng/proj.ios/MobClick.h diff --git a/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj b/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj index c3ce573636..3500b4499c 100644 --- a/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj +++ b/plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj/project.pbxproj @@ -8,9 +8,8 @@ /* Begin PBXBuildFile section */ FA09A305168ADAEC008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A304168ADAEC008C1C7B /* Foundation.framework */; }; - FA09A352168ADCA6008C1C7B /* AnalyticsUmeng.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */; }; - FA42959E173A4B6500462EF7 /* UmengWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = FA42959D173A4B6500462EF7 /* UmengWrapper.m */; }; - FA866506168BE06A0073E055 /* libMobClickLibrary.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA866505168BE06A0073E055 /* libMobClickLibrary.a */; }; + FAB6DFE91756F3B600C90D89 /* AnalyticsUmeng.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DFE61756F3B600C90D89 /* AnalyticsUmeng.m */; }; + FAB6DFEA1756F3B600C90D89 /* libMobClickLibrary.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB6DFE71756F3B600C90D89 /* libMobClickLibrary.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -28,12 +27,10 @@ /* Begin PBXFileReference section */ FA09A301168ADAEC008C1C7B /* libPluginUmeng.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginUmeng.a; sourceTree = BUILT_PRODUCTS_DIR; }; FA09A304168ADAEC008C1C7B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - FA09A34E168ADC97008C1C7B /* AnalyticsUmeng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsUmeng.h; sourceTree = ""; }; - FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnalyticsUmeng.mm; sourceTree = ""; }; - FA09A351168ADCA6008C1C7B /* MobClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobClick.h; sourceTree = ""; }; - FA42959C173A4B6500462EF7 /* UmengWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UmengWrapper.h; sourceTree = ""; }; - FA42959D173A4B6500462EF7 /* UmengWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UmengWrapper.m; sourceTree = ""; }; - FA866505168BE06A0073E055 /* libMobClickLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libMobClickLibrary.a; sourceTree = ""; }; + FAB6DFE51756F3B600C90D89 /* AnalyticsUmeng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsUmeng.h; sourceTree = ""; }; + FAB6DFE61756F3B600C90D89 /* AnalyticsUmeng.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnalyticsUmeng.m; sourceTree = ""; }; + FAB6DFE71756F3B600C90D89 /* libMobClickLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libMobClickLibrary.a; sourceTree = ""; }; + FAB6DFE81756F3B600C90D89 /* MobClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobClick.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -42,7 +39,7 @@ buildActionMask = 2147483647; files = ( FA09A305168ADAEC008C1C7B /* Foundation.framework in Frameworks */, - FA866506168BE06A0073E055 /* libMobClickLibrary.a in Frameworks */, + FAB6DFEA1756F3B600C90D89 /* libMobClickLibrary.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -52,8 +49,10 @@ FA09A2F6168ADAEC008C1C7B = { isa = PBXGroup; children = ( - FA09A34F168ADCA6008C1C7B /* ios */, - FA09A34D168ADC97008C1C7B /* include */, + FAB6DFE51756F3B600C90D89 /* AnalyticsUmeng.h */, + FAB6DFE61756F3B600C90D89 /* AnalyticsUmeng.m */, + FAB6DFE71756F3B600C90D89 /* libMobClickLibrary.a */, + FAB6DFE81756F3B600C90D89 /* MobClick.h */, FA09A303168ADAEC008C1C7B /* Frameworks */, FA09A302168ADAEC008C1C7B /* Products */, ); @@ -75,28 +74,6 @@ name = Frameworks; sourceTree = ""; }; - FA09A34D168ADC97008C1C7B /* include */ = { - isa = PBXGroup; - children = ( - FA09A34E168ADC97008C1C7B /* AnalyticsUmeng.h */, - ); - name = include; - path = ../include; - sourceTree = ""; - }; - FA09A34F168ADCA6008C1C7B /* ios */ = { - isa = PBXGroup; - children = ( - FA42959C173A4B6500462EF7 /* UmengWrapper.h */, - FA42959D173A4B6500462EF7 /* UmengWrapper.m */, - FA866505168BE06A0073E055 /* libMobClickLibrary.a */, - FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */, - FA09A351168ADCA6008C1C7B /* MobClick.h */, - ); - name = ios; - path = ../platform/ios; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -148,8 +125,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - FA09A352168ADCA6008C1C7B /* AnalyticsUmeng.mm in Sources */, - FA42959E173A4B6500462EF7 /* UmengWrapper.m in Sources */, + FAB6DFE91756F3B600C90D89 /* AnalyticsUmeng.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/plugin/plugins/umeng/platform/ios/libMobClickLibrary.a.REMOVED.git-id b/plugin/plugins/umeng/proj.ios/libMobClickLibrary.a.REMOVED.git-id similarity index 100% rename from plugin/plugins/umeng/platform/ios/libMobClickLibrary.a.REMOVED.git-id rename to plugin/plugins/umeng/proj.ios/libMobClickLibrary.a.REMOVED.git-id diff --git a/plugin/plugins/weibo/include/SocialWeibo.h b/plugin/plugins/weibo/include/SocialWeibo.h deleted file mode 100755 index 394a257285..0000000000 --- a/plugin/plugins/weibo/include/SocialWeibo.h +++ /dev/null @@ -1,74 +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. -****************************************************************************/ -#ifndef __CCX_SOCIAL_WEIBO_H__ -#define __CCX_SOCIAL_WEIBO_H__ - -#include "ProtocolSocial.h" - -namespace cocos2d { namespace plugin { - -class SocialWeibo : public ProtocolSocial -{ - PLUGIN_REGISTER_DECL(SocialWeibo) -public: - /** - @brief plugin initialization - */ - virtual bool init(); - - /** - @brief config the developer info - @param devInfo This parameter is the info of developer, must contains key: - WeiboAppKey The app key of weibo account - WeiboRedirectUrl The redirect url of weibo account - @warning Must invoke this interface before other interfaces. - And invoked only once. - */ - virtual void configDeveloperInfo(TSocialDeveloperInfo devInfo); - - /** - @brief pay for product - @param info The info of product, can contains key: - SharedText The text need to share - SharedImagePath The full path of image file need to share (optinal) - @warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. - */ - virtual void share(TShareInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); - - virtual const char* getPluginVersion() { return "v0.1.01"; }; - virtual const char* getSDKVersion(); - - virtual ~SocialWeibo(); -}; - -}} // namespace cocos2d { namespace plugin { - -#endif /* __CCX_SOCIAL_WEIBO_H__ */ diff --git a/plugin/plugins/weibo/jsb_weibo.ini b/plugin/plugins/weibo/jsb_weibo.ini deleted file mode 100644 index f6ef4983ec..0000000000 --- a/plugin/plugins/weibo/jsb_weibo.ini +++ /dev/null @@ -1,60 +0,0 @@ -[weibo] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = pluginx_weibo - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = plugin - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include/linux -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(androidndkdir)s/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.6/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.1/include -clang_flags = -nostdinc -x c++ - -cocos_headers = -I%(pluginxdir)s/protocols/include -I%(pluginxdir)s/plugins/weibo/include - -cocos_flags = -DANDROID - -cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s - -# what headers to parse -headers = %(pluginxdir)s/plugins/weibo/include/SocialWeibo.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = SocialWeibo - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = *::[createPlugin] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# CCSet is special and we will use a hand-written constructor -abstract_classes = SocialWeibo - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = yes - diff --git a/plugin/plugins/weibo/platform/android/SocialWeibo.cpp b/plugin/plugins/weibo/platform/android/SocialWeibo.cpp deleted file mode 100755 index f311270bb3..0000000000 --- a/plugin/plugins/weibo/platform/android/SocialWeibo.cpp +++ /dev/null @@ -1,77 +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. -****************************************************************************/ -#include "SocialWeibo.h" -#include "PluginUtils.h" - -namespace cocos2d { namespace plugin { - -PLUGIN_REGISTER_IMPL(SocialWeibo) - -SocialWeibo::~SocialWeibo() -{ -} - -/** -@brief plugin initialization -*/ -bool SocialWeibo::init() -{ - return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.SocialWeibo"); -} - -/** -@brief config the developer info -@param devInfo This parameter is the info of developer, must contains key: - WeiboAppKey The app key of weibo account - WeiboRedirectUrl The redirect url of weibo account -@warning Must invoke this interface before other interfaces. - And invoked only once. -*/ -void SocialWeibo::configDeveloperInfo(TSocialDeveloperInfo devInfo) -{ - ProtocolSocial::configDeveloperInfo(devInfo); -} - -/** -@brief pay for product -@param info The info of product, must contains key: - SharedText The text need to share - SharedImagePath The full path of image file need to share (optinal) -*/ -void SocialWeibo::share(TShareInfo info) -{ - ProtocolSocial::share(info); -} - -const char* SocialWeibo::getSDKVersion() -{ - return ProtocolSocial::getSDKVersion(); -} - -void SocialWeibo::setDebugMode(bool debug) -{ - ProtocolSocial::setDebugMode(debug); -} - -}} // namespace cocos2d { namespace plugin { diff --git a/plugin/plugins/weibo/proj.android/.project b/plugin/plugins/weibo/proj.android/.project index 345896bff7..960d21be03 100755 --- a/plugin/plugins/weibo/proj.android/.project +++ b/plugin/plugins/weibo/proj.android/.project @@ -30,16 +30,4 @@ com.android.ide.eclipse.adt.AndroidNature org.eclipse.jdt.core.javanature - - - android - 2 - PARENT-1-PROJECT_LOC/platform/android - - - include - 2 - PARENT-1-PROJECT_LOC/include - - diff --git a/plugin/plugins/weibo/proj.android/build_native.sh b/plugin/plugins/weibo/proj.android/build_native.sh deleted file mode 100755 index 0b272b9465..0000000000 --- a/plugin/plugins/weibo/proj.android/build_native.sh +++ /dev/null @@ -1,20 +0,0 @@ -# set params -PLUGIN_ANDROID_ROOT=$(cd "$(dirname "$0")"; pwd) - -if [ ! "${PLUGIN_ROOT}" ]; then - PLUGIN_ROOT="$PLUGIN_ANDROID_ROOT"/../.. -fi - -# build -"$ANDROID_NDK_ROOT"/ndk-build -C "$PLUGIN_ANDROID_ROOT" \ -NDK_MODULE_PATH="$PLUGIN_ROOT" - -echo -if [ "0" != "$?" ]; then - echo "Build error occoured!!!" - exit 1 -fi - -echo -echo "Native build action success." -exit 0 \ No newline at end of file diff --git a/plugin/plugins/weibo/proj.android/jni/Android.mk b/plugin/plugins/weibo/proj.android/jni/Android.mk deleted file mode 100755 index 695a6a352d..0000000000 --- a/plugin/plugins/weibo/proj.android/jni/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := PluginWeiboStatic - -LOCAL_MODULE_FILENAME := libPluginWeiboStatic - -LOCAL_SRC_FILES := \ -$(addprefix ../../platform/android/, \ - SocialWeibo.cpp \ -) \ - -LOCAL_CFLAGS := - -LOCAL_EXPORT_CFLAGS := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include - -LOCAL_WHOLE_STATIC_LIBRARIES := PluginProtocolStatic - -LOCAL_LDLIBS := -landroid -LOCAL_LDLIBS += -llog - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module, protocols/proj.android/jni) diff --git a/plugin/plugins/weibo/proj.android/jni/Application.mk b/plugin/plugins/weibo/proj.android/jni/Application.mk deleted file mode 100755 index 68e59b0ee9..0000000000 --- a/plugin/plugins/weibo/proj.android/jni/Application.mk +++ /dev/null @@ -1,7 +0,0 @@ -# it is needed for ndk-r5 -APP_STL := gnustl_static -APP_CPPFLAGS += -frtti -APP_MODULES := PluginWeiboStatic -APP_ABI :=armeabi -#APP_ABI :=x86 -#APP_ABI :=mips mips-r2 mips-r2-sf armeabi diff --git a/plugin/plugins/weibo/proj.android/src/org/cocos2dx/plugin/SocialWeibo.java b/plugin/plugins/weibo/proj.android/src/org/cocos2dx/plugin/SocialWeibo.java index 6a9e074440..8a50d5f5ad 100755 --- a/plugin/plugins/weibo/proj.android/src/org/cocos2dx/plugin/SocialWeibo.java +++ b/plugin/plugins/weibo/proj.android/src/org/cocos2dx/plugin/SocialWeibo.java @@ -26,7 +26,6 @@ package org.cocos2dx.plugin; import java.io.IOException; import java.util.Hashtable; -import org.cocos2dx.plugin.InterfaceSocial.ShareAdapter; import com.weibo.sdk.android.Oauth2AccessToken; import com.weibo.sdk.android.Weibo; @@ -43,7 +42,7 @@ import android.net.NetworkInfo; import android.os.Bundle; import android.util.Log; -public class SocialWeibo implements ShareAdapter { +public class SocialWeibo implements InterfaceSocial { private static final String LOG_TAG = "SocialWeibo"; private static Activity mContext = null; @@ -109,12 +108,12 @@ public class SocialWeibo implements ShareAdapter { LogD("share invoked " + info.toString()); mShareInfo = info; if (! networkReachable()) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "Network error!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "Network error!"); return; } if (! isInitialized) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "Initialize failed!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "Initialize failed!"); return; } @@ -154,7 +153,7 @@ public class SocialWeibo implements ShareAdapter { } public static void shareResult(int ret, String msg) { - InterfaceSocial.onShareResult(mSocialAdapter, ret, msg); + SocialWrapper.onShareResult(mSocialAdapter, ret, msg); LogD("SocialWeibo result : " + ret + " msg : " + msg); } @@ -170,24 +169,24 @@ public class SocialWeibo implements ShareAdapter { mSocialAdapter.shareToWeibo(); } catch (Exception e) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "认证失败!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "认证失败!"); LogE("anthorize failed", e); } } @Override public void onError(WeiboDialogError e) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, e.getMessage()); + shareResult(SocialWrapper.SHARERESULT_FAIL, e.getMessage()); } @Override public void onCancel() { - shareResult(InterfaceSocial.SHARERESULT_FAIL, "取消认证!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "取消认证!"); } @Override public void onWeiboException(WeiboException e) { - shareResult(InterfaceSocial.SHARERESULT_FAIL, e.getMessage()); + shareResult(SocialWrapper.SHARERESULT_FAIL, e.getMessage()); } } @@ -206,19 +205,24 @@ public class SocialWeibo implements ShareAdapter { @Override public void onComplete(String arg0) { - shareResult(InterfaceSocial.SHARERESULT_SUCCESS, "分享成功!"); + shareResult(SocialWrapper.SHARERESULT_SUCCESS, "分享成功!"); } @Override public void onError(WeiboException arg0) { LogE("Share onError", arg0); - shareResult(InterfaceSocial.SHARERESULT_FAIL, "分享失败!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "分享失败!"); } @Override public void onIOException(IOException arg0) { LogE("Share onIOException", arg0); - shareResult(InterfaceSocial.SHARERESULT_FAIL, "分享失败!"); + shareResult(SocialWrapper.SHARERESULT_FAIL, "分享失败!"); } } + + @Override + public String getPluginVersion() { + return "0.2.0"; + } } diff --git a/plugin/protocols/PluginManager.cpp b/plugin/protocols/PluginManager.cpp index 64a3e3170d..f39a893ca2 100644 --- a/plugin/protocols/PluginManager.cpp +++ b/plugin/protocols/PluginManager.cpp @@ -22,20 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "PluginManager.h" -#include -#include +#include "PluginFactory.h" + namespace cocos2d { namespace plugin { -typedef struct tagPluginInfo -{ - PluginCreator pfnCreator; - PluginProtocol* pInstance; -}PluginInfo; - -typedef std::map PluginCreatorMap; -typedef std::pair PluginCreatorPair; - -static PluginCreatorMap* s_pCreatorMap = NULL; static PluginManager* s_pPluginManager = NULL; PluginManager::PluginManager(void) @@ -44,14 +34,15 @@ PluginManager::PluginManager(void) PluginManager::~PluginManager() { - PluginCreatorMap::iterator it = s_pCreatorMap->begin(); - for (;it != s_pCreatorMap->end();++it) + std::map::iterator it = m_pluginsMap.begin(); + for (;it != m_pluginsMap.end();++it) { - if (it->second.pInstance != NULL) { - delete it->second.pInstance; - it->second.pInstance = NULL; + if (it->second != NULL) { + delete it->second; + it->second = NULL; } } + m_pluginsMap.clear(); } PluginManager* PluginManager::getInstance() @@ -70,6 +61,8 @@ void PluginManager::end() delete s_pPluginManager; s_pPluginManager = NULL; } + + PluginFactory::purgeFactory(); } PluginProtocol* PluginManager::loadPlugin(const char* name) @@ -77,18 +70,20 @@ PluginProtocol* PluginManager::loadPlugin(const char* name) PluginProtocol* pRet = NULL; do { if (name == NULL || strlen(name) == 0) break; - PluginCreatorMap::iterator it = s_pCreatorMap->find(name); - if (it != s_pCreatorMap->end()) + std::map::iterator it = m_pluginsMap.find(name); + if (it != m_pluginsMap.end()) { - if (it->second.pInstance == NULL) { - it->second.pInstance = it->second.pfnCreator(); + if (it->second == NULL) { + it->second = PluginFactory::getInstance()->createPlugin(name); } - else { - // LOGD("The plugin has been loaded, return the loaded instance directly."); - } - pRet = it->second.pInstance; + pRet = it->second; + } else + { + pRet = PluginFactory::getInstance()->createPlugin(name); + m_pluginsMap["name"] = pRet; } } while (false); + return pRet; } @@ -96,28 +91,15 @@ void PluginManager::unloadPlugin(const char* name) { do { if (name == NULL || strlen(name) == 0) break; - PluginCreatorMap::iterator it = s_pCreatorMap->find(name); - if (it != s_pCreatorMap->end()) + std::map::iterator it = m_pluginsMap.find(name); + if (it != m_pluginsMap.end()) { - if (it->second.pInstance != NULL) { - delete it->second.pInstance; - it->second.pInstance = NULL; + if (it->second != NULL) { + delete it->second; + it->second = NULL; } } } while (false); } -bool PluginManager::registerPlugin(const char* name, PluginCreator pfnCreator) -{ - if (s_pCreatorMap == NULL) { - static PluginCreatorMap s_CreatorMap; - s_pCreatorMap = &s_CreatorMap; - } - PluginInfo info; - info.pfnCreator = pfnCreator; - info.pInstance = NULL; - s_pCreatorMap->insert(PluginCreatorPair(name, info)); - return true; -} - }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/include/RegisterPlugin.h b/plugin/protocols/PluginParam.cpp similarity index 55% rename from plugin/protocols/include/RegisterPlugin.h rename to plugin/protocols/PluginParam.cpp index ea59063e37..d747c7d9b0 100644 --- a/plugin/protocols/include/RegisterPlugin.h +++ b/plugin/protocols/PluginParam.cpp @@ -21,44 +21,45 @@ 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. ****************************************************************************/ -#ifndef __CCX_REGISTERPLUGIN_H__ -#define __CCX_REGISTERPLUGIN_H__ + +#include "PluginParam.h" namespace cocos2d { namespace plugin { -class PluginProtocol; - -typedef PluginProtocol* (*PluginCreator)(); - -/** - @brief RegisterPlugin class is only for associating plugin name with plugin creator. - Plugin developers don't need to use this class directly. - Using the macros 'PLUGIN_REGISTER_DECL' and 'PLUGIN_REGISTER_IMPL' instead. -*/ -class RegisterPlugin +PluginParam::PluginParam(int nValue) +: m_nValue(nValue) { -public: - RegisterPlugin(const char* name, PluginCreator pfnCreator); -}; + m_type = kParamTypeInt; +} -#define PLUGIN_REGISTER_DECL(type) \ - private: type() {} \ - static RegisterPlugin s_registerPlugin; \ - public: static PluginProtocol* createPlugin(); \ - virtual const char* getPluginName() { return #type; }; +PluginParam::PluginParam(float fValue) +: m_fValue(fValue) +{ + m_type = kParamTypeFloat; +} -#define PLUGIN_REGISTER_IMPL(type) \ -RegisterPlugin type::s_registerPlugin(#type, type::createPlugin); \ -PluginProtocol* type::createPlugin() { \ - type* pRet = new type(); \ - if (pRet) { \ - if (!pRet->init()) { \ - delete pRet; pRet = NULL; \ - } \ - } \ - return pRet; \ +PluginParam::PluginParam(bool bValue) +: m_bValue(bValue) +{ + m_type = kParamTypeBool; +} + +PluginParam::PluginParam(const char* strValue) +: m_strValue(strValue) +{ + m_type = kParamTypeString; +} + +PluginParam::PluginParam(std::map mapValue) +: m_mapValue(mapValue) +{ + m_type = kParamTypeMap; +} + +PluginParam::PluginParam(std::map strMapValue) +: m_strMapValue(strMapValue) +{ + m_type = kParamTypeStringMap; } }} //namespace cocos2d { namespace plugin { - -#endif /* __CCX_REGISTERPLUGIN_H__ */ diff --git a/plugin/protocols/RegisterPlugin.cpp b/plugin/protocols/include/PluginFactory.h similarity index 69% rename from plugin/protocols/RegisterPlugin.cpp rename to plugin/protocols/include/PluginFactory.h index 7d5f3229c2..c331eb87f3 100644 --- a/plugin/protocols/RegisterPlugin.cpp +++ b/plugin/protocols/include/PluginFactory.h @@ -21,14 +21,31 @@ 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. ****************************************************************************/ -#include "RegisterPlugin.h" -#include "PluginManager.h" +#ifndef __CCX_PLUGIN_FACTORY_H__ +#define __CCX_PLUGIN_FACTORY_H__ namespace cocos2d { namespace plugin { -RegisterPlugin::RegisterPlugin(const char* name, PluginCreator pfnCreator) +class PluginProtocol; +class PluginManager; +class PluginFactory { - PluginManager::getInstance()->registerPlugin(name, pfnCreator); -} +public: + virtual ~PluginFactory(); + /** Get singleton of PluginFactory */ + static PluginFactory* getInstance(); + + /** Destory the instance of PluginFactory */ + static void purgeFactory(); + +private: + friend class PluginManager; + PluginFactory(void); + + /** create the plugin by name */ + PluginProtocol* createPlugin(const char* name); +}; }} //namespace cocos2d { namespace plugin { + +#endif /* __CCX_PLUGIN_FACTORY_H__ */ diff --git a/plugin/protocols/include/PluginManager.h b/plugin/protocols/include/PluginManager.h index f618625086..8800487f78 100644 --- a/plugin/protocols/include/PluginManager.h +++ b/plugin/protocols/include/PluginManager.h @@ -25,7 +25,8 @@ THE SOFTWARE. #define __CCX_PLUGINMANAGER_H__ #include "PluginProtocol.h" -#include "RegisterPlugin.h" +#include +#include namespace cocos2d { namespace plugin { @@ -42,10 +43,10 @@ public: PluginProtocol* loadPlugin(const char* name); /** unload the plugin by name */ void unloadPlugin(const char* name); + private: - friend class RegisterPlugin; - bool registerPlugin(const char* name, PluginCreator pfnCreator); PluginManager(void); + std::map m_pluginsMap; }; }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/include/PluginParam.h b/plugin/protocols/include/PluginParam.h new file mode 100644 index 0000000000..f37d748cf4 --- /dev/null +++ b/plugin/protocols/include/PluginParam.h @@ -0,0 +1,96 @@ +/**************************************************************************** +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. +****************************************************************************/ +#ifndef __CCX_PLUGIN_PARAM_H__ +#define __CCX_PLUGIN_PARAM_H__ + +#include +#include + +namespace cocos2d { namespace plugin { + +class PluginParam +{ +public: + PluginParam(int nValue); + PluginParam(float fValue); + PluginParam(bool bValue); + PluginParam(const char* strValue); + PluginParam(std::map mapValue); + PluginParam(std::map strMapValue); + + typedef enum{ + kParamTypeNull = 0, + kParamTypeInt, + kParamTypeFloat, + kParamTypeBool, + kParamTypeString, + kParamTypeMap, + kParamTypeStringMap, + } ParamType; + + inline ParamType getCurrentType() { + return m_type; + } + + inline int getIntValue() { + return m_nValue; + } + + inline float getFloatValue() { + return m_fValue; + } + + inline bool getBoolValue() { + return m_bValue; + } + + inline const char* getStringValue() { + return m_strValue.c_str(); + } + + inline std::map getMapValue() { + return m_mapValue; + } + + inline std::map getStrMapValue() { + return m_strMapValue; + } + +private: + PluginParam(); + +private: + ParamType m_type; + + int m_nValue; + float m_fValue; + bool m_bValue; + std::string m_strValue; + std::map m_mapValue; + std::map m_strMapValue; +}; + +}} //namespace cocos2d { namespace plugin { + +#endif /* __CCX_PLUGIN_PARAM_H__ */ diff --git a/plugin/protocols/include/PluginProtocol.h b/plugin/protocols/include/PluginProtocol.h index f59917e082..d385db1ee7 100644 --- a/plugin/protocols/include/PluginProtocol.h +++ b/plugin/protocols/include/PluginProtocol.h @@ -24,36 +24,49 @@ THE SOFTWARE. #ifndef __CCX_IPLUGIN_H__ #define __CCX_IPLUGIN_H__ -#include "RegisterPlugin.h" +#include "PluginParam.h" namespace cocos2d { namespace plugin { /** The super class for all plugins. */ - +class PluginFactory; class PluginProtocol { public: - virtual ~PluginProtocol() {} - virtual bool init() { return true; } - void setUserData(void* userData) { m_pUserData = userData; } - void* getUserData() { return m_pUserData; } + virtual ~PluginProtocol(); /** @brief plug-in info methods(name, version, SDK version) */ - virtual const char* getPluginName() = 0; - virtual const char* getPluginVersion() = 0; + inline const char* getPluginName() { return m_pPluginName; } + const char* getPluginVersion(); + const char* getSDKVersion(); /** @brief switch debug plug-in on/off */ - virtual void setDebugMode(bool bDebug) {} + void setDebugMode(bool bDebug); + + /** + * @brief methods for reflections + */ + void callFuncWithParam(const char* funcName, PluginParam* param, ...); + const char* callStringFuncWithParam(const char* funcName, PluginParam* param, ...); + int callIntFuncWithParam(const char* funcName, PluginParam* param, ...); + bool callBoolFuncWithParam(const char* funcName, PluginParam* param, ...); + float callFloatFuncWithParam(const char* funcName, PluginParam* param, ...); protected: PluginProtocol() {} - void* m_pUserData; + +private: + friend class PluginFactory; + inline void setPluginName(const char* name) { + m_pPluginName = name; + } + const char* m_pPluginName; }; }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/include/ProtocolAds.h b/plugin/protocols/include/ProtocolAds.h index 97e347f8e0..4ca675cf1d 100644 --- a/plugin/protocols/include/ProtocolAds.h +++ b/plugin/protocols/include/ProtocolAds.h @@ -66,6 +66,8 @@ public: class ProtocolAds : public PluginProtocol { public: + ProtocolAds(); + virtual ~ProtocolAds(); typedef enum { kBannerAd = 0, @@ -82,11 +84,6 @@ public: kPosBottomRight, } AdsPos; - /** - @brief plugin initialization - */ - virtual bool init(); - /** @brief config the application info @param devInfo This parameter is the info of aplication, @@ -94,7 +91,7 @@ public: @warning Must invoke this interface before other interfaces. And invoked only once. */ - virtual void configDeveloperInfo(TAdsDeveloperInfo devInfo); + void configDeveloperInfo(TAdsDeveloperInfo devInfo); /** @brief show adview @@ -106,26 +103,20 @@ public: @param pos The position where the adview be shown. (only used when type is kBannerAd) */ - virtual void showAds(AdsType type, int sizeEnum = 0, AdsPos pos = kPosCenter); + void showAds(AdsType type, int sizeEnum = 0, AdsPos pos = kPosCenter); /** @brief Hide the adview @param type The adview type need to hide. */ - virtual void hideAds(AdsType type); + void hideAds(AdsType type); /** @brief Spend the points. Use this method to notify server spend points. @param points Need spend number of points */ - virtual void spendPoints(int points); - - /** - @brief Set whether needs to output logs to console. - @param debug If true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); + void spendPoints(int points); /** @brief set the Ads listener @@ -136,15 +127,6 @@ public: void onAdsResult(AdsResultCode code, const char* msg); void onPlayerGetPoints(int points); - virtual const char* getPluginVersion() { return "ProtocolAds, v0.1.01 , subclass should override this interface!"; }; - virtual const char* getSDKVersion(); - virtual const char* getPluginName() = 0; - -protected: - ProtocolAds(); -public: - virtual ~ProtocolAds(); - protected: AdsListener* m_pListener; }; diff --git a/plugin/protocols/include/ProtocolAnalytics.h b/plugin/protocols/include/ProtocolAnalytics.h index 17a7ce7809..9360c9eb69 100644 --- a/plugin/protocols/include/ProtocolAnalytics.h +++ b/plugin/protocols/include/ProtocolAnalytics.h @@ -36,78 +36,59 @@ typedef std::map< std::string, std::string > LogEventParamMap; class ProtocolAnalytics : public PluginProtocol { public: + ProtocolAnalytics(); + virtual ~ProtocolAnalytics(); - /** - @brief plugin initialization - */ - virtual bool init(); - /** @brief Start a new session. @param appKey The identity of the application. */ - virtual void startSession(const char* appKey); + void startSession(const char* appKey); /** @brief Stop a session. @warning This interface only worked on android */ - virtual void stopSession(); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - @note It must be invoked before calling startSession. - */ - virtual void setDebugMode(bool debug); - + void stopSession(); + /** @brief Set the timeout for expiring a session. @param millis In milliseconds as the unit of time. @note It must be invoked before calling startSession. */ - virtual void setSessionContinueMillis(long millis); + void setSessionContinueMillis(long millis); /** @brief log an error @param errorId The identity of error @param message Extern message for the error */ - virtual void logError(const char* errorId, const char* message); + void logError(const char* errorId, const char* message); /** @brief log an event. @param eventId The identity of event @param paramMap Extern parameters of the event, use NULL if not needed. */ - virtual void logEvent(const char* eventId, LogEventParamMap* paramMap = NULL); + void logEvent(const char* eventId, LogEventParamMap* paramMap = NULL); /** @brief Track an event begin. @param eventId The identity of event */ - virtual void logTimedEventBegin(const char* eventId); + void logTimedEventBegin(const char* eventId); /** @brief Track an event end. @param eventId The identity of event */ - virtual void logTimedEventEnd(const char* eventId); + void logTimedEventEnd(const char* eventId); /** @brief Whether to catch uncaught exceptions to server. @warning This interface only worked on android. */ - virtual void setCaptureUncaughtException(bool enabled); - - virtual const char* getPluginVersion() { return "ProtocolAnalytics, v0.1.01 , subclass should override this interface!"; }; - virtual const char* getSDKVersion(); - virtual const char* getPluginName() = 0; - -protected: - ProtocolAnalytics(); -public: - virtual ~ProtocolAnalytics(); + void setCaptureUncaughtException(bool enabled); }; }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/include/ProtocolIAP.h b/plugin/protocols/include/ProtocolIAP.h index 73c501c282..f2d4c8df69 100644 --- a/plugin/protocols/include/ProtocolIAP.h +++ b/plugin/protocols/include/ProtocolIAP.h @@ -50,11 +50,8 @@ public: class ProtocolIAP : public PluginProtocol { public: - - /** - @brief plugin initialization - */ - virtual bool init(); + ProtocolIAP(); + virtual ~ProtocolIAP(); /** @brief config the developer info @@ -63,7 +60,7 @@ public: @warning Must invoke this interface before other interfaces. And invoked only once. */ - virtual void configDeveloperInfo(TIAPDeveloperInfo devInfo); + void configDeveloperInfo(TIAPDeveloperInfo devInfo); /** @brief pay for product @@ -74,13 +71,7 @@ public: @warning For different plugin, the parameter should have other keys to pay. Look at the manual of plugins. */ - virtual void payForProduct(TProductInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); + void payForProduct(TProductInfo info); /** @breif set the result listener @@ -94,15 +85,6 @@ public: */ void onPayResult(PayResultCode ret, const char* msg); - virtual const char* getPluginVersion() { return "ProtocolIAP, v0.1.01 , subclass should override this interface!"; }; - virtual const char* getSDKVersion(); - virtual const char* getPluginName() = 0; - -protected: - ProtocolIAP(); -public: - virtual ~ProtocolIAP(); - protected: static bool m_bPaying; diff --git a/plugin/protocols/include/ProtocolSocial.h b/plugin/protocols/include/ProtocolSocial.h index c6fe7434c2..e0423c551d 100755 --- a/plugin/protocols/include/ProtocolSocial.h +++ b/plugin/protocols/include/ProtocolSocial.h @@ -50,11 +50,8 @@ public: class ProtocolSocial : public PluginProtocol { public: - - /** - @brief plugin initialization - */ - virtual bool init(); + ProtocolSocial(); + virtual ~ProtocolSocial(); /** @brief config the social developer info @@ -63,7 +60,7 @@ public: @warning Must invoke this interface before other interfaces. And invoked only once. */ - virtual void configDeveloperInfo(TSocialDeveloperInfo devInfo); + void configDeveloperInfo(TSocialDeveloperInfo devInfo); /** @brief share information @@ -73,13 +70,7 @@ public: @warning For different plugin, the parameter should have other keys to share. Look at the manual of plugins. */ - virtual void share(TShareInfo info); - - /** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - */ - virtual void setDebugMode(bool debug); + void share(TShareInfo info); /** @breif set the result listener @@ -93,14 +84,8 @@ public: */ void onShareResult(ShareResultCode ret, const char* msg); - virtual const char* getPluginVersion() { return "ProtocolSocial, v0.1.0, subclass should override this interface!"; }; - virtual const char* getSDKVersion(); - virtual const char* getPluginName() = 0; - -protected: - ProtocolSocial(); -public: - virtual ~ProtocolSocial(); + const char* getPluginVersion() { return "ProtocolSocial, v0.1.0, subclass should override this interface!"; }; + const char* getSDKVersion(); protected: ShareResultListener* m_pListener; diff --git a/plugin/protocols/platform/android/PluginFactory.cpp b/plugin/protocols/platform/android/PluginFactory.cpp new file mode 100644 index 0000000000..6b4ba4a89b --- /dev/null +++ b/plugin/protocols/platform/android/PluginFactory.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +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. +****************************************************************************/ +#include "PluginFactory.h" +#include "PluginUtils.h" +#include "PluginJniHelper.h" +#include "ProtocolAds.h" +#include "ProtocolAnalytics.h" +#include "ProtocolIAP.h" +#include "ProtocolSocial.h" + +namespace cocos2d { namespace plugin { + +enum { + kPluginAds = 1, + kPluginAnalytics, + kPluginIAP, + kPluginSocial, +}; + +#define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugin/" + +static PluginFactory* s_pFactory = NULL; + +PluginFactory::PluginFactory() +{ + +} + +PluginFactory::~PluginFactory() +{ + +} + +PluginFactory* PluginFactory::getInstance() +{ + if (NULL == s_pFactory) + { + s_pFactory = new PluginFactory(); + } + + return s_pFactory; +} + +void PluginFactory::purgeFactory() +{ + if (NULL != s_pFactory) + { + delete s_pFactory; + s_pFactory = NULL; + } +} + +/** create the plugin by name */ +PluginProtocol* PluginFactory::createPlugin(const char* name) +{ + PluginProtocol* pRet = NULL; + do + { + if (name == NULL || strlen(name) == 0) break; + + std::string jClassName = ANDROID_PLUGIN_PACKAGE_PREFIX; + jClassName.append(name); + PluginUtils::outputLog("PluginFactory", "Java class name of plugin %s is : %s", name, jClassName.c_str()); + + PluginJniMethodInfo t; + if (! PluginJniHelper::getStaticMethodInfo(t + , "org/cocos2dx/plugin/PluginWrapper" + , "initPlugin" + , "(Ljava/lang/String;)Ljava/lang/Object;")) + { + PluginUtils::outputLog("PluginFactory", "Can't find method initPlugin in class org.cocos2dx.plugin.PluginWrapper"); + break; + } + + jstring clsName = t.env->NewStringUTF(jClassName.c_str()); + jobject jObj = t.env->CallStaticObjectMethod(t.classID, t.methodID, clsName); + t.env->DeleteLocalRef(clsName); + t.env->DeleteLocalRef(t.classID); + if (jObj == NULL) + { + PluginUtils::outputLog("PluginFactory", "Can't find java class %s", jClassName.c_str()); + break; + } + + if (! PluginJniHelper::getStaticMethodInfo(t + , "org/cocos2dx/plugin/PluginWrapper" + , "getPluginType" + , "(Ljava/lang/Object;)I")) + { + PluginUtils::outputLog("PluginFactory", "Can't find method getPluginType in class org.cocos2dx.plugin.PluginWrapper"); + break; + } + int curType = t.env->CallStaticIntMethod(t.classID, t.methodID, jObj); + t.env->DeleteLocalRef(t.classID); + PluginUtils::outputLog("PluginFactory", "The type of plugin %s is : %d", name, curType); + + switch (curType) + { + case kPluginAds: + pRet = new ProtocolAds(); + break; + case kPluginAnalytics: + pRet = new ProtocolAnalytics(); + break; + case kPluginIAP: + pRet = new ProtocolIAP(); + break; + case kPluginSocial: + pRet = new ProtocolSocial(); + break; + default: + break; + } + + if (pRet != NULL) + { + pRet->setPluginName(name); + PluginUtils::initJavaPlugin(pRet, jObj, jClassName.c_str()); + } + } while(0); + + return pRet; +} + +}} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/android/PluginJniHelper.cpp b/plugin/protocols/platform/android/PluginJniHelper.cpp index d70198e2b1..8890ee74e7 100644 --- a/plugin/protocols/platform/android/PluginJniHelper.cpp +++ b/plugin/protocols/platform/android/PluginJniHelper.cpp @@ -109,6 +109,10 @@ extern "C" methodID = pEnv->GetStaticMethodID(classID, methodName, paramCode); if (! methodID) { + if(pEnv->ExceptionCheck()) + { + pEnv->ExceptionClear(); + } LOGD("Failed to find static method id of %s", methodName); break; } @@ -140,7 +144,11 @@ extern "C" methodID = pEnv->GetMethodID(classID, methodName, paramCode); if (! methodID) { - LOGD("Failed to find method id of %s", methodName); + if(pEnv->ExceptionCheck()) + { + pEnv->ExceptionClear(); + } + LOGD("Failed to find method %s in class %s", methodName, className); break; } @@ -190,16 +198,6 @@ void PluginJniHelper::setJavaVM(JavaVM *javaVM) m_psJavaVM = javaVM; } -string PluginJniHelper::m_externalAssetPath; - -const char* PluginJniHelper::getExternalAssetPath() { - return m_externalAssetPath.c_str(); -} - -void PluginJniHelper::setExternalAssetPath(const char * externalAssetPath) { - m_externalAssetPath = externalAssetPath; -} - jclass PluginJniHelper::getClassID(const char *className, JNIEnv *env) { return getClassID_(className, env); diff --git a/plugin/protocols/platform/android/PluginJniHelper.h b/plugin/protocols/platform/android/PluginJniHelper.h index 8c48c286bc..6fb3080b0d 100644 --- a/plugin/protocols/platform/android/PluginJniHelper.h +++ b/plugin/protocols/platform/android/PluginJniHelper.h @@ -41,8 +41,6 @@ class PluginJniHelper public: static JavaVM* getJavaVM(); static void setJavaVM(JavaVM *javaVM); - static const char* getExternalAssetPath(); - static void setExternalAssetPath(const char* externalAssetPath); static jclass getClassID(const char *className, JNIEnv *env=0); static bool getStaticMethodInfo(PluginJniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); static bool getMethodInfo(PluginJniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); @@ -50,7 +48,6 @@ public: private: static JavaVM *m_psJavaVM; - static std::string m_externalAssetPath; }; } diff --git a/plugin/protocols/platform/android/PluginJniMacros.h b/plugin/protocols/platform/android/PluginJniMacros.h new file mode 100644 index 0000000000..ef56b1e771 --- /dev/null +++ b/plugin/protocols/platform/android/PluginJniMacros.h @@ -0,0 +1,145 @@ +/**************************************************************************** +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. +****************************************************************************/ +#ifndef __PLUGIN_JNI_MACROS_H__ +#define __PLUGIN_JNI_MACROS_H__ + +#define return_if_fails(cond) if (!(cond)) return; +#define return_val_if_fails(cond, ret) if(!(cond)) return (ret); + +#define CALL_BASERET_JAVA_FUNC_WITH_PARAM(retType, paramCode, param, retCode, defaultRet) \ +retType ret = defaultRet; \ +return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); \ +return_val_if_fails(paramCode != NULL && strlen(paramCode) > 0, ret); \ +PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); \ +return_val_if_fails(pData != NULL, ret); \ + \ +PluginJniMethodInfo t; \ +if (PluginJniHelper::getMethodInfo(t \ + , pData->jclassName.c_str() \ + , funcName \ + , paramCode)) \ +{ \ + if (NULL != param) \ + { \ + ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \ + } else { \ + ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \ + } \ + t.env->DeleteLocalRef(t.classID); \ +} \ +return ret; \ + + + +#define CALL_JAVA_FUNC(retType, retCode, defaultRet, jRetCode) \ +retType ret = defaultRet; \ +PluginJavaData* pData = PluginUtils::getPluginJavaData(this); \ +if (NULL == pData) { \ + PluginUtils::outputLog("PluginProtocol", "Can't find java data for plugin : %s", this->getPluginName()); \ + return ret; \ +} \ + \ +std::string paramCode; \ +if (NULL == param) \ +{ \ + paramCode = "()"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), NULL); \ +} else \ +{ \ + PluginParam* pRetParam = NULL; \ + std::map allParams; \ + va_list argp; \ + int argno = 0; \ + PluginParam* pArg = NULL; \ + \ + allParams["Param1"] = param; \ + va_start( argp, param ); \ + while (1) \ + { \ + pArg = va_arg(argp, PluginParam*); \ + if (pArg == NULL) \ + { \ + break; \ + } \ + argno++; \ + char strKey[8] = { 0 }; \ + sprintf(strKey, "Param%d", argno + 1); \ + allParams[strKey] = pArg; \ + } \ + va_end(argp); \ + \ + PluginParam tempParam(allParams); \ + if (argno == 0) \ + { \ + pRetParam = param; \ + } \ + else \ + { \ + pRetParam = &tempParam; \ + } \ + switch(pRetParam->getCurrentType()) \ + { \ + case PluginParam::kParamTypeInt: \ + paramCode = "(I)"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getIntValue()); \ + break; \ + case PluginParam::kParamTypeFloat: \ + paramCode = "(F)"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getFloatValue()); \ + break; \ + case PluginParam::kParamTypeBool: \ + paramCode = "(Z)"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getBoolValue()); \ + break; \ + case PluginParam::kParamTypeString: \ + { \ + jstring jstr = PluginUtils::getEnv()->NewStringUTF(pRetParam->getStringValue()); \ + paramCode = "(Ljava/lang/String;)"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), jstr); \ + PluginUtils::getEnv()->DeleteLocalRef(jstr); \ + } \ + break; \ + case PluginParam::kParamTypeStringMap: \ + case PluginParam::kParamTypeMap: \ + { \ + jobject jMap = PluginUtils::getJObjFromParam(pRetParam); \ + paramCode = "(Lorg/json/JSONObject;)"; \ + paramCode.append(jRetCode); \ + ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), jMap); \ + PluginUtils::getEnv()->DeleteLocalRef(jMap); \ + } \ + break; \ + default: \ + break; \ + } \ +} \ +return ret; \ + + +#endif // __PLUGIN_JNI_MACROS_H__ diff --git a/plugin/protocols/platform/android/PluginProtocol.cpp b/plugin/protocols/platform/android/PluginProtocol.cpp new file mode 100644 index 0000000000..82a1364448 --- /dev/null +++ b/plugin/protocols/platform/android/PluginProtocol.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** +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. +****************************************************************************/ +#include "PluginProtocol.h" +#include "PluginUtils.h" + +#define LOG_TAG "PluginProtocol" + +namespace cocos2d { namespace plugin { + +PluginProtocol::~PluginProtocol() +{ + PluginUtils::erasePluginJavaData(this); +} + +const char* PluginProtocol::getPluginVersion() +{ + std::string verName; + + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + if (PluginJniHelper::getMethodInfo(t + , pData->jclassName.c_str() + , "getPluginVersion" + , "()Ljava/lang/String;")) + { + jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); + verName = PluginJniHelper::jstring2string(ret); + } + return verName.c_str(); +} + +const char* PluginProtocol::getSDKVersion() +{ + std::string verName; + + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + if (PluginJniHelper::getMethodInfo(t + , pData->jclassName.c_str() + , "getSDKVersion" + , "()Ljava/lang/String;")) + { + jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); + verName = PluginJniHelper::jstring2string(ret); + } + return verName.c_str(); +} + +void PluginProtocol::setDebugMode(bool isDebugMode) +{ + PluginUtils::callJavaFunctionWithName_oneParam(this, "setDebugMode", "(Z)V", isDebugMode); +} + +void PluginProtocol::callFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + if (NULL == pData) { + PluginUtils::outputLog(LOG_TAG, "Can't find java data for plugin : %s", this->getPluginName()); + return; + } + + if (NULL == param) + { + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "()V", NULL); + } else + { + PluginParam* pRetParam = NULL; + std::map allParams; + va_list argp; + int argno = 0; + PluginParam* pArg = NULL; + + allParams["Param1"] = param; + va_start( argp, param ); + while (1) + { + pArg = va_arg(argp, PluginParam*); + if (pArg == NULL) + { + break; + } + argno++; + char strKey[8] = { 0 }; + sprintf(strKey, "Param%d", argno + 1); + allParams[strKey] = pArg; + } + va_end(argp); + + PluginParam tempParam(allParams); + if (argno == 0) + { + pRetParam = param; + } + else + { + pRetParam = &tempParam; + } + + switch(pRetParam->getCurrentType()) + { + case PluginParam::kParamTypeInt: + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "(I)V", pRetParam->getIntValue()); + break; + case PluginParam::kParamTypeFloat: + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "(F)V", pRetParam->getFloatValue()); + break; + case PluginParam::kParamTypeBool: + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "(Z)V", pRetParam->getBoolValue()); + break; + case PluginParam::kParamTypeString: + { + jstring jstr = PluginUtils::getEnv()->NewStringUTF(pRetParam->getStringValue()); + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "(Ljava/lang/String;)V", jstr); + PluginUtils::getEnv()->DeleteLocalRef(jstr); + } + break; + case PluginParam::kParamTypeStringMap: + case PluginParam::kParamTypeMap: + { + jobject jMap = PluginUtils::getJObjFromParam(pRetParam); + PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "(Lorg/json/JSONObject;)V", jMap); + PluginUtils::getEnv()->DeleteLocalRef(jMap); + } + break; + default: + break; + } + } +} + +const char* PluginProtocol::callStringFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_JAVA_FUNC(const char*, String, "", "Ljava/lang/String;") +} + +int PluginProtocol::callIntFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_JAVA_FUNC(int, Int, 0, "I") +} + +bool PluginProtocol::callBoolFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_JAVA_FUNC(bool, Bool, false, "Z") +} + +float PluginProtocol::callFloatFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_JAVA_FUNC(float, Float, 0.0f, "F") +} + +}} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/android/PluginUtils.cpp b/plugin/protocols/platform/android/PluginUtils.cpp index 4f6b6ff99e..abe494e05e 100644 --- a/plugin/protocols/platform/android/PluginUtils.cpp +++ b/plugin/protocols/platform/android/PluginUtils.cpp @@ -25,69 +25,36 @@ THE SOFTWARE. #include #include +#define MAX_LOG_LEN 256 + namespace cocos2d { namespace plugin { #define JAVAVM cocos2d::PluginJniHelper::getJavaVM() -#if 1 -#define LOG_TAG "PluginUtils" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - -static cocos2d::plugin::PluginProtocol* s_pPluginInstance = NULL; - -extern "C" { - -JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_PluginWrapper_nativeInitPlugin(JNIEnv* env, jobject thiz, jobject obj, jstring className) +jobject PluginUtils::createJavaMapObject(std::map* paramMap) { - if (s_pPluginInstance != NULL) { - cocos2d::plugin::PluginJavaData* pUserData = new cocos2d::plugin::PluginJavaData(); - pUserData->jobj = env->NewGlobalRef(obj); - pUserData->jclassName = cocos2d::PluginJniHelper::jstring2string(className); - cocos2d::plugin::PluginUtils::setPluginJavaData(s_pPluginInstance, pUserData); - s_pPluginInstance = NULL; - } -} - -} - -jobject PluginUtils::createJavaMapObject(PluginJniMethodInfo&t, std::map* paramMap) -{ - jclass class_Hashtable = t.env->FindClass("java/util/Hashtable"); - jmethodID construct_method = t.env->GetMethodID( class_Hashtable, "","()V"); - jobject obj_Map = t.env->NewObject( class_Hashtable, construct_method, ""); + JNIEnv* env = getEnv(); + jclass class_Hashtable = env->FindClass("java/util/Hashtable"); + jmethodID construct_method = env->GetMethodID( class_Hashtable, "","()V"); + jobject obj_Map = env->NewObject( class_Hashtable, construct_method, ""); if (paramMap != NULL) { - jmethodID add_method= t.env->GetMethodID( class_Hashtable,"put","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + jmethodID add_method= env->GetMethodID( class_Hashtable,"put","(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); for (std::map::const_iterator it = paramMap->begin(); it != paramMap->end(); ++it) { - t.env->CallObjectMethod(obj_Map, add_method, t.env->NewStringUTF(it->first.c_str()), t.env->NewStringUTF(it->second.c_str())); + env->CallObjectMethod(obj_Map, add_method, env->NewStringUTF(it->first.c_str()), env->NewStringUTF(it->second.c_str())); } } - t.env->DeleteLocalRef(class_Hashtable); + env->DeleteLocalRef(class_Hashtable); return obj_Map; } -bool PluginUtils::initJavaPlugin(PluginProtocol* pPlugin, const char* className) +void PluginUtils::initJavaPlugin(PluginProtocol* pPlugin, jobject jObj, const char* className) { - return_val_if_fails(className != NULL && strlen(className) > 0, false); - bool bRet = false; - PluginJniMethodInfo t; - s_pPluginInstance = pPlugin; - if (PluginJniHelper::getStaticMethodInfo(t - , "org/cocos2dx/plugin/PluginWrapper" - , "initPlugin" - , "(Ljava/lang/String;)Z")) - { - jstring jclassName = t.env->NewStringUTF(className); - bRet = (bool)t.env->CallStaticBooleanMethod(t.classID, t.methodID, jclassName); - t.env->DeleteLocalRef(jclassName); - t.env->DeleteLocalRef(t.classID); - } - - return bRet; + cocos2d::plugin::PluginJavaData* pUserData = new cocos2d::plugin::PluginJavaData(); + pUserData->jobj = PluginUtils::getEnv()->NewGlobalRef(jObj); + pUserData->jclassName = className; + cocos2d::plugin::PluginUtils::setPluginJavaData(pPlugin, pUserData); } JNIEnv* PluginUtils::getEnv() @@ -98,13 +65,13 @@ JNIEnv* PluginUtils::getEnv() { if (JAVAVM->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) { - LOGD("Failed to get the environment using GetEnv()"); + outputLog("PluginUtils", "Failed to get the environment using GetEnv()"); break; } if (JAVAVM->AttachCurrentThread(&env, 0) < 0) { - LOGD("Failed to get the environment using AttachCurrentThread()"); + outputLog("PluginUtils", "Failed to get the environment using AttachCurrentThread()"); break; } @@ -169,7 +136,7 @@ void PluginUtils::erasePluginJavaData(PluginProtocol* pKeyObj) } JNIEnv* pEnv = getEnv(); - LOGD("Delete global reference."); + outputLog("PluginUtils", "Delete global reference."); pEnv->DeleteGlobalRef(jobj); delete pData; } @@ -177,4 +144,106 @@ void PluginUtils::erasePluginJavaData(PluginProtocol* pKeyObj) } } +void PluginUtils::outputLog(const char* logTag, const char* pFormat, ...) +{ + char buf[MAX_LOG_LEN + 1]; + + va_list args; + va_start(args, pFormat); + vsnprintf(buf, MAX_LOG_LEN, pFormat, args); + va_end(args); + + __android_log_print(ANDROID_LOG_DEBUG, logTag, buf); +} + +jobject PluginUtils::getJObjFromParam(PluginParam* param) +{ + if (NULL == param) + { + return NULL; + } + + jobject obj = NULL; + PluginJniMethodInfo t; + JNIEnv* env = PluginUtils::getEnv(); + + switch(param->getCurrentType()) + { + case PluginParam::kParamTypeInt: + if (PluginJniHelper::getStaticMethodInfo(t, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;")) + { + obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, param->getIntValue()); + } + break; + case PluginParam::kParamTypeFloat: + if (PluginJniHelper::getStaticMethodInfo(t, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;")) + { + obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, param->getFloatValue()); + } + break; + case PluginParam::kParamTypeBool: + if (PluginJniHelper::getStaticMethodInfo(t, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;")) + { + obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, param->getBoolValue()); + } + break; + case PluginParam::kParamTypeString: + obj = env->NewStringUTF(param->getStringValue()); + break; + case PluginParam::kParamTypeStringMap: + { + jclass cls = env->FindClass("org/json/JSONObject"); + jmethodID mid = env->GetMethodID(cls,"","()V"); + obj = env->NewObject(cls,mid); + std::map::iterator it; + std::map mapParam = param->getStrMapValue(); + for (it = mapParam.begin(); it != mapParam.end(); it++) + { + PluginJniMethodInfo tInfo; + if (PluginJniHelper::getMethodInfo(tInfo, "org/json/JSONObject", "put", "(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;")) + { + jstring strKey = tInfo.env->NewStringUTF(it->first.c_str()); + jstring strValue = tInfo.env->NewStringUTF(it->second.c_str()); + + tInfo.env->CallObjectMethod(obj, tInfo.methodID, strKey, strValue); + tInfo.env->DeleteLocalRef(tInfo.classID); + + tInfo.env->DeleteLocalRef(strKey); + tInfo.env->DeleteLocalRef(strValue); + } + } + } + break; + case PluginParam::kParamTypeMap: + { + jclass cls = env->FindClass("org/json/JSONObject"); + jmethodID mid = env->GetMethodID(cls,"","()V"); + obj = env->NewObject(cls,mid); + + std::map::iterator it; + std::map mapParam = param->getMapValue(); + for (it = mapParam.begin(); it != mapParam.end(); it++) + { + PluginJniMethodInfo tInfo; + if (PluginJniHelper::getMethodInfo(tInfo, "org/json/JSONObject", "put", "(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;")) + { + jstring strKey = tInfo.env->NewStringUTF(it->first.c_str()); + jobject objValue = PluginUtils::getJObjFromParam(it->second); + + tInfo.env->CallObjectMethod(obj, tInfo.methodID, strKey, objValue); + tInfo.env->DeleteLocalRef(tInfo.classID); + + tInfo.env->DeleteLocalRef(strKey); + PluginUtils::getEnv()->DeleteLocalRef(objValue); + } + } + } + break; + default: + break; + } + + return obj; +} + }}// namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/android/PluginUtils.h b/plugin/protocols/platform/android/PluginUtils.h index 37de6cd58a..8d4e1465d1 100644 --- a/plugin/protocols/platform/android/PluginUtils.h +++ b/plugin/protocols/platform/android/PluginUtils.h @@ -25,21 +25,19 @@ THE SOFTWARE. #define __PLUGIN_UTILS_H__ #include "PluginJniHelper.h" -#include #include "PluginJavaData.h" #include "PluginProtocol.h" #include +#include "PluginParam.h" +#include "PluginJniMacros.h" namespace cocos2d { namespace plugin { -#define return_if_fails(cond) if (!(cond)) return; -#define return_val_if_fails(cond, ret) if(!(cond)) return (ret); - class PluginUtils { public: - static jobject createJavaMapObject(PluginJniMethodInfo&t, std::map* paramMap); - static bool initJavaPlugin(PluginProtocol* pPlugin, const char* className); + static jobject createJavaMapObject(std::map* paramMap); + static void initJavaPlugin(PluginProtocol* pPlugin, jobject jObj, const char* className); static JNIEnv* getEnv(); static PluginJavaData* getPluginJavaData(PluginProtocol* pKeyObj); @@ -48,37 +46,84 @@ public: static PluginProtocol* getPluginPtr(std::string className); + static jobject getJObjFromParam(PluginParam* param); + + // methods have no return value template - static void callJavaFunctionWithName_oneBaseType(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) + static void callJavaFunctionWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) { return_if_fails(funcName != NULL && strlen(funcName) > 0); return_if_fails(paramCode != NULL && strlen(paramCode) > 0); PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); - PluginJniMethodInfo t; + return_if_fails(pData != NULL); + + PluginJniMethodInfo t; if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() , funcName , paramCode)) { - t.env->CallVoidMethod(pData->jobj, t.methodID, param); + if (param != NULL) + { + t.env->CallVoidMethod(pData->jobj, t.methodID, param); + } else { + t.env->CallVoidMethod(pData->jobj, t.methodID); + } t.env->DeleteLocalRef(t.classID); } } - - static void callJavaFunctionWithName(PluginProtocol* thiz, const char* funcName) + + // methods return value is string + template + static const char* callJavaStringFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) { - return_if_fails(funcName != NULL && strlen(funcName) > 0); + const char* ret = ""; + return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); + return_val_if_fails(paramCode != NULL && strlen(paramCode) > 0, ret); PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); + return_val_if_fails(pData != NULL, ret); + PluginJniMethodInfo t; if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() , funcName - , "()V")) + , paramCode)) { - t.env->CallVoidMethod(pData->jobj, t.methodID); + jstring strRet = NULL; + if (param != NULL) + { + strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID, param); + } else { + strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID); + } + ret = PluginJniHelper::jstring2string(strRet).c_str(); t.env->DeleteLocalRef(t.classID); } + return ret; } + + // methods return value is int + template + static int callJavaIntFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) + { + CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0) + } + + // methods return value is float + template + static float callJavaFloatFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) + { + CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f) + } + + // methods return value is bool + template + static bool callJavaBoolFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) + { + CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false) + } + + static void outputLog(const char* logTag, const char* pFormat, ...); }; }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/android/ProtocolAds.cpp b/plugin/protocols/platform/android/ProtocolAds.cpp index 4e4ba6a87d..8bdc34029c 100644 --- a/plugin/protocols/platform/android/ProtocolAds.cpp +++ b/plugin/protocols/platform/android/ProtocolAds.cpp @@ -27,24 +27,17 @@ THE SOFTWARE. #include "PluginUtils.h" #include "PluginJavaData.h" -#if 1 -#define LOG_TAG "ProtocolAds" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - namespace cocos2d { namespace plugin { extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_InterfaceAds_nativeOnAdsResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) { + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_AdsWrapper_nativeOnAdsResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) { std::string strMsg = PluginJniHelper::jstring2string(msg); std::string strClassName = PluginJniHelper::jstring2string(className); PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); - LOGD("nativeOnAdsResult(), Get plugin ptr : %p", pPlugin); + PluginUtils::outputLog("ProtocolAds", "nativeOnAdsResult(), Get plugin ptr : %p", pPlugin); if (pPlugin != NULL) { - LOGD("nativeOnAdsResult(), Get plugin name : %s", pPlugin->getPluginName()); + PluginUtils::outputLog("ProtocolAds", "nativeOnAdsResult(), Get plugin name : %s", pPlugin->getPluginName()); ProtocolAds* pAds = dynamic_cast(pPlugin); if (pAds != NULL) { @@ -53,13 +46,13 @@ extern "C" { } } - JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_InterfaceAds_nativeOnPlayerGetPoints(JNIEnv* env, jobject thiz, jstring className, jint points) { + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_AdsWrapper_nativeOnPlayerGetPoints(JNIEnv* env, jobject thiz, jstring className, jint points) { std::string strClassName = PluginJniHelper::jstring2string(className); PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); - LOGD("nativeOnPlayerGetPoints(), Get plugin ptr : %p", pPlugin); + PluginUtils::outputLog("ProtocolAds", "nativeOnPlayerGetPoints(), Get plugin ptr : %p", pPlugin); if (pPlugin != NULL) { - LOGD("nativeOnPlayerGetPoints(), Get plugin name : %s", pPlugin->getPluginName()); + PluginUtils::outputLog("ProtocolAds", "nativeOnPlayerGetPoints(), Get plugin name : %s", pPlugin->getPluginName()); ProtocolAds* pAds = dynamic_cast(pPlugin); if (pAds != NULL) { @@ -76,19 +69,13 @@ ProtocolAds::ProtocolAds() ProtocolAds::~ProtocolAds() { - PluginUtils::erasePluginJavaData(this); -} - -bool ProtocolAds::init() -{ - return true; } void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo) { if (devInfo.empty()) { - LOGD("The application info is empty!"); + PluginUtils::outputLog("ProtocolAds", "The application info is empty!"); return; } else @@ -101,7 +88,7 @@ void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo) , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map - jobject obj_Map = PluginUtils::createJavaMapObject(t, &devInfo); + jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); @@ -116,7 +103,7 @@ void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) PluginJavaData* pData = PluginUtils::getPluginJavaData(this); PluginJniMethodInfo t; - LOGD("Class name : %s", pData->jclassName.c_str()); + PluginUtils::outputLog("ProtocolAds", "Class name : %s", pData->jclassName.c_str()); if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() , "showAds" @@ -129,34 +116,12 @@ void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) void ProtocolAds::hideAds(AdsType type) { - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "hideAds", "(I)V", type); + PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type); } void ProtocolAds::spendPoints(int points) { - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "spendPoints", "(I)V", points); -} - -const char* ProtocolAds::getSDKVersion() -{ - std::string verName; - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "getSDKVersion" - , "()Ljava/lang/String;")) - { - jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); - verName = PluginJniHelper::jstring2string(ret); - } - return verName.c_str(); -} - -void ProtocolAds::setDebugMode(bool debug) -{ - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setDebugMode", "(Z)V", debug); + PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points); } void ProtocolAds::setAdsListener(AdsListener* pListener) @@ -166,7 +131,7 @@ void ProtocolAds::setAdsListener(AdsListener* pListener) void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg) { - LOGD("ProtocolAds::adsResult invoked!"); + PluginUtils::outputLog("ProtocolAds", "ProtocolAds::adsResult invoked!"); if (m_pListener != NULL) { m_pListener->onAdsResult(code, msg); @@ -175,7 +140,7 @@ void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg) void ProtocolAds::onPlayerGetPoints(int points) { - LOGD("ProtocolAds::onPlayerGetPoints invoked!"); + PluginUtils::outputLog("ProtocolAds", "ProtocolAds::onPlayerGetPoints invoked!"); if (m_pListener != NULL) { m_pListener->onPlayerGetPoints(this, points); diff --git a/plugin/protocols/platform/android/ProtocolAnalytics.cpp b/plugin/protocols/platform/android/ProtocolAnalytics.cpp index edeb4b19b9..a7cd8eca6c 100644 --- a/plugin/protocols/platform/android/ProtocolAnalytics.cpp +++ b/plugin/protocols/platform/android/ProtocolAnalytics.cpp @@ -27,13 +27,6 @@ THE SOFTWARE. #include "PluginUtils.h" #include "PluginJavaData.h" -#if 1 -#define LOG_TAG "ProtocolAnalytics" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - namespace cocos2d { namespace plugin { static void callJavaFunctionWithName_string_map(ProtocolAnalytics* thiz, const char* funcName, const char* keyParam, LogEventParamMap* paramMap) @@ -65,7 +58,7 @@ static void callJavaFunctionWithName_string_map(ProtocolAnalytics* thiz, const c , "(Ljava/lang/String;Ljava/util/Hashtable;)V")) { jstring jeventId = t.env->NewStringUTF(keyParam); - jobject obj_Map = PluginUtils::createJavaMapObject(t, paramMap); + jobject obj_Map = PluginUtils::createJavaMapObject(paramMap); t.env->CallVoidMethod(pData->jobj, t.methodID, jeventId, obj_Map); t.env->DeleteLocalRef(jeventId); t.env->DeleteLocalRef(obj_Map); @@ -80,12 +73,6 @@ ProtocolAnalytics::ProtocolAnalytics() ProtocolAnalytics::~ProtocolAnalytics() { - PluginUtils::erasePluginJavaData(this); -} - -bool ProtocolAnalytics::init() -{ - return true; } void ProtocolAnalytics::startSession(const char* appKey) @@ -109,17 +96,12 @@ void ProtocolAnalytics::stopSession() void ProtocolAnalytics::setSessionContinueMillis(long millis) { - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setSessionContinueMillis", "(I)V", millis); + PluginUtils::callJavaFunctionWithName_oneParam(this, "setSessionContinueMillis", "(I)V", millis); } void ProtocolAnalytics::setCaptureUncaughtException(bool isEnabled) { - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setCaptureUncaughtException", "(Z)V", isEnabled); -} - -void ProtocolAnalytics::setDebugMode(bool isDebugMode) -{ - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setDebugMode", "(Z)V", isDebugMode); + PluginUtils::callJavaFunctionWithName_oneParam(this, "setCaptureUncaughtException", "(Z)V", isEnabled); } void ProtocolAnalytics::logError(const char* errorId, const char* message) @@ -144,23 +126,6 @@ void ProtocolAnalytics::logError(const char* errorId, const char* message) } } -const char* ProtocolAnalytics::getSDKVersion() -{ - std::string verName; - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "getSDKVersion" - , "()Ljava/lang/String;")) - { - jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); - verName = PluginJniHelper::jstring2string(ret); - } - return verName.c_str(); -} - void ProtocolAnalytics::logEvent(const char* eventId, LogEventParamMap* pParams/* = NULL */) { callJavaFunctionWithName_string_map(this, "logEvent", eventId, pParams); diff --git a/plugin/protocols/platform/android/ProtocolIAP.cpp b/plugin/protocols/platform/android/ProtocolIAP.cpp index 86ba7136ef..270e8ea44f 100644 --- a/plugin/protocols/platform/android/ProtocolIAP.cpp +++ b/plugin/protocols/platform/android/ProtocolIAP.cpp @@ -27,25 +27,18 @@ THE SOFTWARE. #include "PluginUtils.h" #include "PluginJavaData.h" -#if 1 -#define LOG_TAG "ProtocolIAP" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - namespace cocos2d { namespace plugin { extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_InterfaceIAP_nativeOnPayResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_IAPWrapper_nativeOnPayResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) { std::string strMsg = PluginJniHelper::jstring2string(msg); std::string strClassName = PluginJniHelper::jstring2string(className); PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); - LOGD("nativeOnPayResult(), Get plugin ptr : %p", pPlugin); + PluginUtils::outputLog("ProtocolIAP", "nativeOnPayResult(), Get plugin ptr : %p", pPlugin); if (pPlugin != NULL) { - LOGD("nativeOnPayResult(), Get plugin name : %s", pPlugin->getPluginName()); + PluginUtils::outputLog("ProtocolIAP", "nativeOnPayResult(), Get plugin name : %s", pPlugin->getPluginName()); ProtocolIAP* pIAP = dynamic_cast(pPlugin); if (pIAP != NULL) { @@ -64,19 +57,13 @@ ProtocolIAP::ProtocolIAP() ProtocolIAP::~ProtocolIAP() { - PluginUtils::erasePluginJavaData(this); -} - -bool ProtocolIAP::init() -{ - return true; } void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo) { if (devInfo.empty()) { - LOGD("The developer info is empty!"); + PluginUtils::outputLog("ProtocolIAP", "The developer info is empty!"); return; } else @@ -89,7 +76,7 @@ void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo) , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map - jobject obj_Map = PluginUtils::createJavaMapObject(t, &devInfo); + jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); @@ -103,7 +90,7 @@ void ProtocolIAP::payForProduct(TProductInfo info) { if (m_bPaying) { - LOGD("Now is paying"); + PluginUtils::outputLog("ProtocolIAP", "Now is paying"); return; } @@ -113,7 +100,7 @@ void ProtocolIAP::payForProduct(TProductInfo info) { onPayResult(kPayFail, "Product info error"); } - LOGD("The product info is empty!"); + PluginUtils::outputLog("ProtocolIAP", "The product info is empty!"); return; } else @@ -129,7 +116,7 @@ void ProtocolIAP::payForProduct(TProductInfo info) , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map - jobject obj_Map = PluginUtils::createJavaMapObject(t, &info); + jobject obj_Map = PluginUtils::createJavaMapObject(&info); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); @@ -153,32 +140,10 @@ void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg) } else { - LOGD("Result listener is null!"); + PluginUtils::outputLog("ProtocolIAP", "Result listener is null!"); } m_curInfo.clear(); - LOGD("Pay result is : %d(%s)", (int) ret, msg); -} - -const char* ProtocolIAP::getSDKVersion() -{ - std::string verName; - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "getSDKVersion" - , "()Ljava/lang/String;")) - { - jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); - verName = PluginJniHelper::jstring2string(ret); - } - return verName.c_str(); -} - -void ProtocolIAP::setDebugMode(bool debug) -{ - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setDebugMode", "(Z)V", debug); + PluginUtils::outputLog("ProtocolIAP", "Pay result is : %d(%s)", (int) ret, msg); } }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/android/ProtocolSocial.cpp b/plugin/protocols/platform/android/ProtocolSocial.cpp index c2a225e1a7..8c933d3380 100755 --- a/plugin/protocols/platform/android/ProtocolSocial.cpp +++ b/plugin/protocols/platform/android/ProtocolSocial.cpp @@ -27,25 +27,18 @@ THE SOFTWARE. #include "PluginUtils.h" #include "PluginJavaData.h" -#if 1 -#define LOG_TAG "ProtocolSocial" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -#else -#define LOGD(...) -#endif - namespace cocos2d { namespace plugin { extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_InterfaceSocial_nativeOnShareResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_SocialWrapper_nativeOnShareResult(JNIEnv* env, jobject thiz, jstring className, jint ret, jstring msg) { std::string strMsg = PluginJniHelper::jstring2string(msg); std::string strClassName = PluginJniHelper::jstring2string(className); PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); - LOGD("nativeOnShareResult(), Get plugin ptr : %p", pPlugin); + PluginUtils::outputLog("ProtocolSocial", "nativeOnShareResult(), Get plugin ptr : %p", pPlugin); if (pPlugin != NULL) { - LOGD("nativeOnShareResult(), Get plugin name : %s", pPlugin->getPluginName()); + PluginUtils::outputLog("ProtocolSocial", "nativeOnShareResult(), Get plugin name : %s", pPlugin->getPluginName()); ProtocolSocial* pSocial = dynamic_cast(pPlugin); if (pSocial != NULL) { @@ -62,19 +55,13 @@ ProtocolSocial::ProtocolSocial() ProtocolSocial::~ProtocolSocial() { - PluginUtils::erasePluginJavaData(this); -} - -bool ProtocolSocial::init() -{ - return true; } void ProtocolSocial::configDeveloperInfo(TSocialDeveloperInfo devInfo) { if (devInfo.empty()) { - LOGD("The developer info is empty!"); + PluginUtils::outputLog("ProtocolSocial", "The developer info is empty!"); return; } else @@ -87,7 +74,7 @@ void ProtocolSocial::configDeveloperInfo(TSocialDeveloperInfo devInfo) , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map - jobject obj_Map = PluginUtils::createJavaMapObject(t, &devInfo); + jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); @@ -105,7 +92,7 @@ void ProtocolSocial::share(TShareInfo info) { onShareResult(kShareFail, "Share info error"); } - LOGD("The Share info is empty!"); + PluginUtils::outputLog("ProtocolSocial", "The Share info is empty!"); return; } else @@ -118,7 +105,7 @@ void ProtocolSocial::share(TShareInfo info) , "(Ljava/util/Hashtable;)V")) { // generate the hashtable from map - jobject obj_Map = PluginUtils::createJavaMapObject(t, &info); + jobject obj_Map = PluginUtils::createJavaMapObject(&info); // invoke java method t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); @@ -141,31 +128,9 @@ void ProtocolSocial::onShareResult(ShareResultCode ret, const char* msg) } else { - LOGD("Result listener is null!"); + PluginUtils::outputLog("ProtocolSocial", "Result listener is null!"); } - LOGD("Share result is : %d(%s)", (int) ret, msg); -} - -const char* ProtocolSocial::getSDKVersion() -{ - std::string verName; - - PluginJavaData* pData = PluginUtils::getPluginJavaData(this); - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , "getSDKVersion" - , "()Ljava/lang/String;")) - { - jstring ret = (jstring)(t.env->CallObjectMethod(pData->jobj, t.methodID)); - verName = PluginJniHelper::jstring2string(ret); - } - return verName.c_str(); -} - -void ProtocolSocial::setDebugMode(bool debug) -{ - PluginUtils::callJavaFunctionWithName_oneBaseType(this, "setDebugMode", "(Z)V", debug); + PluginUtils::outputLog("ProtocolSocial", "Share result is : %d(%s)", (int) ret, msg); } }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/InterfaceAds.h b/plugin/protocols/platform/ios/InterfaceAds.h index d6e3645ef9..7fb01971ed 100644 --- a/plugin/protocols/platform/ios/InterfaceAds.h +++ b/plugin/protocols/platform/ios/InterfaceAds.h @@ -28,9 +28,10 @@ THE SOFTWARE. - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; -- (void) hideAds: (NSNumber*) type; -- (void) spendPoints: (NSNumber*) points; -- (void) setDebugMode: (NSNumber*) debug; +- (void) hideAds: (int) type; +- (void) spendPoints: (int) points; +- (void) setDebugMode: (BOOL) debug; - (NSString*) getSDKVersion; +- (NSString*) getPluginVersion; @end diff --git a/plugin/protocols/platform/ios/InterfaceAnalytics.h b/plugin/protocols/platform/ios/InterfaceAnalytics.h index 239b7f97c7..e834edd12e 100644 --- a/plugin/protocols/platform/ios/InterfaceAnalytics.h +++ b/plugin/protocols/platform/ios/InterfaceAnalytics.h @@ -28,14 +28,15 @@ THE SOFTWARE. - (void) startSession: (NSString*) appKey; - (void) stopSession; -- (void) setSessionContinueMillis: (NSNumber*) millis; -- (void) setCaptureUncaughtException: (NSNumber*) isEnabled; -- (void) setDebugMode: (NSNumber*) isDebugMode; +- (void) setSessionContinueMillis: (long) millis; +- (void) setCaptureUncaughtException: (BOOL) isEnabled; +- (void) setDebugMode: (BOOL) debug; - (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; @end diff --git a/plugin/protocols/platform/ios/InterfaceIAP.h b/plugin/protocols/platform/ios/InterfaceIAP.h index 6c1cb2da20..86af913f05 100644 --- a/plugin/protocols/platform/ios/InterfaceIAP.h +++ b/plugin/protocols/platform/ios/InterfaceIAP.h @@ -28,7 +28,8 @@ THE SOFTWARE. - (void) configDeveloperInfo: (NSMutableDictionary*) cpInfo; - (void) payForProduct: (NSMutableDictionary*) profuctInfo; -- (void) setDebugMode: (NSNumber*) debug; +- (void) setDebugMode: (BOOL) debug; - (NSString*) getSDKVersion; +- (NSString*) getPluginVersion; @end diff --git a/plugin/protocols/platform/ios/InterfaceSocial.h b/plugin/protocols/platform/ios/InterfaceSocial.h index b98eb8827e..00033030da 100644 --- a/plugin/protocols/platform/ios/InterfaceSocial.h +++ b/plugin/protocols/platform/ios/InterfaceSocial.h @@ -24,6 +24,10 @@ THE SOFTWARE. @protocol InterfaceSocial - +- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo; +- (void) share: (NSMutableDictionary*) shareInfo; +- (void) setDebugMode: (BOOL) debug; +- (NSString*) getSDKVersion; +- (NSString*) getPluginVersion; @end diff --git a/plugin/protocols/platform/ios/PluginFactory.mm b/plugin/protocols/platform/ios/PluginFactory.mm new file mode 100644 index 0000000000..09e6b1aba5 --- /dev/null +++ b/plugin/protocols/platform/ios/PluginFactory.mm @@ -0,0 +1,107 @@ +/**************************************************************************** +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. +****************************************************************************/ +#include "PluginFactory.h" +#include "ProtocolAds.h" +#include "ProtocolAnalytics.h" +#include "ProtocolIAP.h" +#include "ProtocolSocial.h" +#include "PluginUtilsIOS.h" + +#import +#import "InterfaceAds.h" +#import "InterfaceAnalytics.h" +#import "InterfaceIAP.h" +#import "InterfaceSocial.h" + +namespace cocos2d { namespace plugin { + +static PluginFactory* s_pFactory = NULL; + +PluginFactory::PluginFactory() +{ + +} + +PluginFactory::~PluginFactory() +{ + +} + +PluginFactory* PluginFactory::getInstance() +{ + if (NULL == s_pFactory) + { + s_pFactory = new PluginFactory(); + } + + return s_pFactory; +} + +void PluginFactory::purgeFactory() +{ + if (NULL != s_pFactory) + { + delete s_pFactory; + s_pFactory = NULL; + } +} + +/** create the plugin by name */ +PluginProtocol* PluginFactory::createPlugin(const char* name) +{ + PluginProtocol* pRet = NULL; + do + { + if (name == NULL || strlen(name) == 0) break; + + NSString* className = [NSString stringWithUTF8String:name]; + id obj = [[NSClassFromString(className) alloc] init]; + if (obj == nil) break; + + if ([obj conformsToProtocol:@protocol(InterfaceAds)]) { + pRet = new ProtocolAds(); + } else + if ([obj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + pRet = new ProtocolAnalytics(); + } else + if ([obj conformsToProtocol:@protocol(InterfaceIAP)]) { + pRet = new ProtocolIAP(); + } else + if ([obj conformsToProtocol:@protocol(InterfaceSocial)]) { + pRet = new ProtocolSocial(); + } else { + PluginUtilsIOS::outputLog("Plugin %s not implements a right protocol", name); + } + + if (pRet != NULL) + { + pRet->setPluginName(name); + PluginUtilsIOS::initOCPlugin(pRet, obj, name); + } + } while(0); + + return pRet; +} + +}} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/PluginOCMacros.h b/plugin/protocols/platform/ios/PluginOCMacros.h new file mode 100644 index 0000000000..f1d3622e81 --- /dev/null +++ b/plugin/protocols/platform/ios/PluginOCMacros.h @@ -0,0 +1,82 @@ +/**************************************************************************** +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. +****************************************************************************/ +#ifndef __PLUGIN_OC_MACROS_H__ +#define __PLUGIN_OC_MACROS_H__ + +#define return_if_fails(cond) if (!(cond)) return; +#define return_val_if_fails(cond, ret) if(!(cond)) return (ret); + + +#define CALL_OC_FUNC(retType, defaultRet, retCode) \ +retType ret = defaultRet; \ +PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); \ +if (NULL == pData) { \ + PluginUtilsIOS::outputLog("Can't find OC data for plugin : %s", this->getPluginName()); \ + return ret; \ +} \ + \ +if (NULL == param) \ +{ \ + ret = PluginUtilsIOS::callOC##retCode##FunctionWithName_oneParam(this, funcName, NULL); \ +} else \ +{ \ + PluginParam* pRetParam = NULL; \ + std::map allParams; \ + va_list argp; \ + int argno = 0; \ + PluginParam* pArg = NULL; \ + \ + allParams["Param1"] = param; \ + va_start( argp, param ); \ + while (1) \ + { \ + pArg = va_arg(argp, PluginParam*); \ + if (pArg == NULL) \ + { \ + break; \ + } \ + argno++; \ + char strKey[8] = { 0 }; \ + sprintf(strKey, "Param%d", argno + 1); \ + allParams[strKey] = pArg; \ + } \ + va_end(argp); \ + \ + PluginParam tempParam(allParams); \ + if (argno == 0) \ + { \ + pRetParam = param; \ + } \ + else \ + { \ + pRetParam = &tempParam; \ + } \ + \ + id ocParam = PluginUtilsIOS::getOCObjFromParam(pRetParam); \ + ret = PluginUtilsIOS::callOC##retCode##FunctionWithName_oneParam(this, funcName, ocParam); \ +} \ +return ret; \ + + +#endif // __PLUGIN_OC_MACROS_H__ diff --git a/plugin/protocols/platform/ios/PluginProtocol.mm b/plugin/protocols/platform/ios/PluginProtocol.mm new file mode 100644 index 0000000000..249e9b6c5e --- /dev/null +++ b/plugin/protocols/platform/ios/PluginProtocol.mm @@ -0,0 +1,155 @@ +/**************************************************************************** +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. +****************************************************************************/ +#include "PluginProtocol.h" +#include "PluginUtilsIOS.h" +#include "PluginOCMacros.h" + +namespace cocos2d { namespace plugin { + +PluginProtocol::~PluginProtocol() +{ + PluginUtilsIOS::erasePluginOCData(this); +} + +const char* PluginProtocol::getPluginVersion() +{ + std::string verName; + + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + if (pData) { + id pOCObj = pData->obj; + SEL selector = NSSelectorFromString(@"getPluginVersion"); + + if ([pOCObj respondsToSelector:selector]) { + NSString* strRet = (NSString*)[pOCObj performSelector:selector]; + verName = [strRet UTF8String]; + } else { + PluginUtilsIOS::outputLog("Can't find function 'getPluginVersion' in class '%s'", pData->className.c_str()); + } + } else { + PluginUtilsIOS::outputLog("Plugin %p not right initilized", this); + } + + return verName.c_str(); +} + +const char* PluginProtocol::getSDKVersion() +{ + std::string verName; + + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + if (pData) { + id pOCObj = pData->obj; + SEL selector = NSSelectorFromString(@"getSDKVersion"); + + if ([pOCObj respondsToSelector:selector]) { + NSString* strRet = (NSString*)[pOCObj performSelector:selector]; + verName = [strRet UTF8String]; + } else { + PluginUtilsIOS::outputLog("Can't find function 'getSDKVersion' in class '%s'", pData->className.c_str()); + } + } else { + PluginUtilsIOS::outputLog("Plugin %s not right initilized", this->getPluginName()); + } + + return verName.c_str(); +} + +void PluginProtocol::setDebugMode(bool isDebugMode) +{ + NSNumber* bDebug = [NSNumber numberWithBool:isDebugMode]; + PluginUtilsIOS::callOCFunctionWithName_oneParam(this, "setDebugMode", bDebug); +} + +void PluginProtocol::callFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + if (NULL == pData) { + PluginUtilsIOS::outputLog("Can't find OC data for plugin : %s", this->getPluginName()); + return; + } + + if (NULL == param) + { + PluginUtilsIOS::callOCFunctionWithName_oneParam(this, funcName, NULL); + } else + { + PluginParam* pRetParam = NULL; + std::map allParams; + va_list argp; + int argno = 0; + PluginParam* pArg = NULL; + + allParams["Param1"] = param; + va_start( argp, param ); + while (1) + { + pArg = va_arg(argp, PluginParam*); + if (pArg == NULL) + { + break; + } + argno++; + char strKey[8] = { 0 }; + sprintf(strKey, "Param%d", argno + 1); + allParams[strKey] = pArg; + } + va_end(argp); + + PluginParam tempParam(allParams); + if (argno == 0) + { + pRetParam = param; + } + else + { + pRetParam = &tempParam; + } + + id ocParam = PluginUtilsIOS::getOCObjFromParam(pRetParam); + PluginUtilsIOS::callOCFunctionWithName_oneParam(this, funcName, ocParam); + } +} + +const char* PluginProtocol::callStringFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_OC_FUNC(const char*, "", String) +} + +int PluginProtocol::callIntFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_OC_FUNC(int, 0, Int) +} + +bool PluginProtocol::callBoolFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_OC_FUNC(bool, false, Bool) +} + +float PluginProtocol::callFloatFuncWithParam(const char* funcName, PluginParam* param, ...) +{ + CALL_OC_FUNC(float, 0.0f, Float) +} + +}} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/PluginUtilsIOS.h b/plugin/protocols/platform/ios/PluginUtilsIOS.h index 4933575de8..18118691b8 100644 --- a/plugin/protocols/platform/ios/PluginUtilsIOS.h +++ b/plugin/protocols/platform/ios/PluginUtilsIOS.h @@ -28,12 +28,10 @@ THE SOFTWARE. #include "PluginProtocol.h" #include #include +#include "PluginParam.h" namespace cocos2d { namespace plugin { -#define return_if_fails(cond) if (!(cond)) return; -#define return_val_if_fails(cond, ret) if(!(cond)) return (ret); - typedef struct _PluginOCData { id obj; @@ -43,7 +41,7 @@ typedef struct _PluginOCData class PluginUtilsIOS { public: - static bool initOCPlugin(PluginProtocol* pPlugin, const char* className); + static void initOCPlugin(PluginProtocol* pPlugin, id ocObj, const char* className); static PluginOCData* getPluginOCData(PluginProtocol* pKeyObj); static void setPluginOCData(PluginProtocol* pKeyObj, PluginOCData* pData); @@ -51,9 +49,39 @@ public: static PluginProtocol* getPluginPtr(id obj); + static id getOCObjFromParam(PluginParam* param); + static NSMutableDictionary* createDictFromMap(std::map* paramMap); - static void callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName); - static void callOCFunctionWithName_Object(PluginProtocol* pPlugin, const char* funcName, id obj); + + /** + @brief method don't have return value + */ + static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); + + /** + @brief method return int value + */ + static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); + + /** + @brief method return float value + */ + static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); + + /** + @brief method return bool value + */ + static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); + + /** + @brief method return string value + */ + static const char* callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); + + static void outputLog(const char* pFormat, ...); + +private: + static id callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param); }; }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/PluginUtilsIOS.mm b/plugin/protocols/platform/ios/PluginUtilsIOS.mm index d63d62f7ed..22bf625d15 100644 --- a/plugin/protocols/platform/ios/PluginUtilsIOS.mm +++ b/plugin/protocols/platform/ios/PluginUtilsIOS.mm @@ -25,26 +25,18 @@ THE SOFTWARE. #include "PluginUtilsIOS.h" #include #import +#include "PluginOCMacros.h" + +#define MAX_LOG_LEN 256 namespace cocos2d { namespace plugin { -bool PluginUtilsIOS::initOCPlugin(PluginProtocol* pPlugin, const char* className) +void PluginUtilsIOS::initOCPlugin(PluginProtocol* pPlugin, id ocObj, const char* className) { - return_val_if_fails(className != NULL && strlen(className) > 0, false); - bool bRet = false; - - NSString* name = [NSString stringWithUTF8String:className]; - id obj = [[NSClassFromString(name) alloc] init]; - if (obj != nil) - { - PluginOCData* pData = new PluginOCData(); - pData->obj = obj; - pData->className = className; - PluginUtilsIOS::setPluginOCData(pPlugin, pData); - bRet = true; - } - - return bRet; + PluginOCData* pData = new PluginOCData(); + pData->obj = ocObj; + pData->className = className; + PluginUtilsIOS::setPluginOCData(pPlugin, pData); } std::map s_PluginOCObjMap; @@ -75,6 +67,54 @@ PluginProtocol* PluginUtilsIOS::getPluginPtr(id obj) return ret; } +id PluginUtilsIOS::getOCObjFromParam(PluginParam* param) +{ + if (NULL == param) + { + return nil; + } + + id obj = nil; + switch(param->getCurrentType()) + { + case PluginParam::kParamTypeInt: + obj = [NSNumber numberWithInt:param->getIntValue()]; + break; + case PluginParam::kParamTypeFloat: + obj = [NSNumber numberWithFloat:param->getFloatValue()]; + break; + case PluginParam::kParamTypeBool: + obj = [NSNumber numberWithBool:param->getBoolValue()]; + break; + case PluginParam::kParamTypeString: + obj = [NSString stringWithUTF8String:param->getStringValue()]; + break; + case PluginParam::kParamTypeStringMap: + { + std::map mapValue = param->getStrMapValue(); + obj = createDictFromMap(&mapValue); + } + break; + case PluginParam::kParamTypeMap: + { + obj = [NSMutableDictionary dictionary]; + std::map paramMap = param->getMapValue(); + std::map::const_iterator it; + for (it = paramMap.begin(); it != paramMap.end(); ++it) + { + NSString* pKey = [NSString stringWithUTF8String:it->first.c_str()]; + id objValue = PluginUtilsIOS::getOCObjFromParam(it->second); + [obj setValue:objValue forKey:pKey]; + } + } + break; + default: + break; + } + + return obj; +} + void PluginUtilsIOS::setPluginOCData(PluginProtocol* pKeyObj, PluginOCData* pData) { erasePluginOCData(pKeyObj); @@ -123,50 +163,112 @@ NSMutableDictionary* PluginUtilsIOS::createDictFromMap(std::map 0); - - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin); - if (pData) { - id pOCObj = pData->obj; - NSString* strFuncName = [NSString stringWithUTF8String:funcName]; - SEL selector = NSSelectorFromString(strFuncName); - - const char* className = class_getName([pOCObj class]); - NSString* strClassName = [NSString stringWithUTF8String:className]; - if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector]; - NSLog(@"Function '%@' in class '%@' invoked", strFuncName, strClassName); - } else { - NSLog(@"Can't find function '%@' in class '%@'", strFuncName, strClassName); - } - } else { - printf("Can't find function '%s' in plugin %p", funcName, pPlugin); - } -} - -void PluginUtilsIOS::callOCFunctionWithName_Object(PluginProtocol* pPlugin, const char* funcName, id obj) +void PluginUtilsIOS::callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) { return_if_fails(funcName != NULL && strlen(funcName) > 0); PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin); if (pData) { id pOCObj = pData->obj; + NSString* strFuncName = [NSString stringWithUTF8String:funcName]; + if (param != nil) { + strFuncName = [strFuncName stringByAppendingString:@":"]; + } SEL selector = NSSelectorFromString(strFuncName); - - const char* className = class_getName([pOCObj class]); - NSString* strClassName = [NSString stringWithUTF8String:className]; if ([pOCObj respondsToSelector:selector]) { - [pOCObj performSelector:selector withObject:obj]; - NSLog(@"Function '%@' in class '%@' invoked", strFuncName, strClassName); + if (param == nil) { + [pOCObj performSelector:selector]; + } else { + [pOCObj performSelector:selector withObject:param]; + } } else { - NSLog(@"Can't find function '%@' in class '%@'", strFuncName, strClassName); + outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str()); } } else { - printf("Can't find function '%s' in plugin %p", funcName, pPlugin); + PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName()); } } +int PluginUtilsIOS::callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) +{ + int ret = (NSInteger)callRetFunction(pPlugin, funcName, param); + return ret; +} + +float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) +{ + float ret = 0.0f; + NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param); + if (nil != pRet) { + ret = [pRet floatValue]; + } + + return ret; +} + +bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) +{ + bool ret = false; + NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param); + if (nil != pRet) { + ret = [pRet boolValue]; + } + + return ret; +} + +const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) +{ + const char* ret = ""; + NSString* pRet = (NSString*)callRetFunction(pPlugin, funcName, param); + if (nil != pRet) { + ret = [pRet UTF8String]; + } + + return ret; +} + +id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param) +{ + id ret = nil; + return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); + + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin); + if (pData) { + id pOCObj = pData->obj; + + NSString* strFuncName = [NSString stringWithUTF8String:funcName]; + if (param != nil) { + strFuncName = [strFuncName stringByAppendingString:@":"]; + } + SEL selector = NSSelectorFromString(strFuncName); + if ([pOCObj respondsToSelector:selector]) { + if (param == nil) { + ret = [pOCObj performSelector:selector]; + } else { + ret = [pOCObj performSelector:selector withObject:param]; + } + } else { + outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str()); + } + } else { + PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName()); + } + + return ret; +} + +void PluginUtilsIOS::outputLog(const char* pFormat, ...) +{ + printf("Plugin-x: "); + char szBuf[MAX_LOG_LEN+1] = {0}; + va_list ap; + va_start(ap, pFormat); + vsnprintf(szBuf, MAX_LOG_LEN, pFormat, ap); + va_end(ap); + printf("%s", szBuf); + printf("\n"); +} + }}// namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/ProtocolAds.mm b/plugin/protocols/platform/ios/ProtocolAds.mm index 0e9a2cb85c..1902f0eec0 100644 --- a/plugin/protocols/platform/ios/ProtocolAds.mm +++ b/plugin/protocols/platform/ios/ProtocolAds.mm @@ -23,6 +23,7 @@ ****************************************************************************/ #include "ProtocolAds.h" +#include "PluginUtilsIOS.h" #import "InterfaceAds.h" namespace cocos2d { namespace plugin { @@ -36,29 +37,61 @@ ProtocolAds::~ProtocolAds() { } -bool ProtocolAds::init() -{ - return true; -} - void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo) { + if (devInfo.empty()) + { + PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName()); + return; + } + else + { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo); + [curObj configDeveloperInfo:pDict]; + } + } } void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { + NSObject* curObj = ocObj; + [curObj showAds:type size:sizeEnum position:pos]; + } } void ProtocolAds::hideAds(AdsType type) { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { + NSObject* curObj = ocObj; + [curObj hideAds:type]; + } } void ProtocolAds::spendPoints(int points) { -} - -void ProtocolAds::setDebugMode(bool debug) -{ + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { + NSObject* curObj = ocObj; + [curObj spendPoints:points]; + } } // For the callbak methods @@ -83,9 +116,4 @@ void ProtocolAds::onPlayerGetPoints(int points) } } -const char* ProtocolAds::getSDKVersion() -{ - return "Subclass should override this interface"; -} - }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/ProtocolAnalytics.mm b/plugin/protocols/platform/ios/ProtocolAnalytics.mm index ae04635971..3fb65f6b01 100644 --- a/plugin/protocols/platform/ios/ProtocolAnalytics.mm +++ b/plugin/protocols/platform/ios/ProtocolAnalytics.mm @@ -36,19 +36,21 @@ ProtocolAnalytics::~ProtocolAnalytics() PluginUtilsIOS::erasePluginOCData(this); } -bool ProtocolAnalytics::init() -{ - return true; -} - /** @brief Start a new session. @param appKey The identity of the application. */ void ProtocolAnalytics::startSession(const char* appKey) { - NSString* pStrKey = [NSString stringWithUTF8String:appKey]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "startSession:", pStrKey); + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + NSString* pStrKey = [NSString stringWithUTF8String:appKey]; + [curObj startSession:pStrKey]; + } } /** @@ -57,18 +59,14 @@ void ProtocolAnalytics::startSession(const char* appKey) */ void ProtocolAnalytics::stopSession() { - PluginUtilsIOS::callOCFunctionWithName(this, "stopSession"); -} - -/** - @brief Set whether needs to output logs to console. - @param debug if true debug mode enabled, or debug mode disabled. - @note It must be invoked before calling startSession. - */ -void ProtocolAnalytics::setDebugMode(bool debug) -{ - NSNumber* bDebug = [NSNumber numberWithBool:debug]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setDebugMode:", bDebug); + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + [curObj stopSession]; + } } /** @@ -78,8 +76,14 @@ void ProtocolAnalytics::setDebugMode(bool debug) */ void ProtocolAnalytics::setSessionContinueMillis(long millis) { - NSNumber* lMillis = [NSNumber numberWithLong:millis]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setSessionContinueMillis:", lMillis); + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + [curObj setSessionContinueMillis:millis]; + } } /** @@ -90,18 +94,14 @@ void ProtocolAnalytics::setSessionContinueMillis(long millis) void ProtocolAnalytics::logError(const char* errorId, const char* message) { PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (! pData) { - return; - } + assert(pData != NULL); - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"logError:withMsg:"); - if ([pOCObj respondsToSelector:selector]) { - - NSString* strErrID = [NSString stringWithUTF8String:errorId]; - NSString* strMsg = [NSString stringWithUTF8String:message]; - [pOCObj logError:strErrID withMsg:strMsg]; - NSLog(@"logError withMsg in OC class invoked!"); + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + NSString* pError = [NSString stringWithUTF8String:errorId]; + NSString* pMsg = [NSString stringWithUTF8String:message]; + [curObj logError:pError withMsg:pMsg]; } } @@ -113,24 +113,14 @@ void ProtocolAnalytics::logError(const char* errorId, const char* message) void ProtocolAnalytics::logEvent(const char* eventId, LogEventParamMap* paramMap) { PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (! pData) { - return; - } + assert(pData != NULL); - id pOCObj = pData->obj; - NSString* strEventID = [NSString stringWithUTF8String:eventId]; - - if (paramMap == NULL) { - PluginUtilsIOS::callOCFunctionWithName_Object(this, "logEvent:", strEventID); - NSLog(@"logEvent(no paramsters) in OC class invoked!"); - } else { - SEL selector = NSSelectorFromString(@"logEvent:withParam:"); - if ([pOCObj respondsToSelector:selector]) { - - NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); - [pOCObj logEvent:strEventID withParam:dict]; - NSLog(@"logEvent(with parameters) in OC class invoked!"); - } + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + NSString* pId = [NSString stringWithUTF8String:eventId]; + NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap); + [curObj logEvent:pId withParam:dict]; } } @@ -140,8 +130,15 @@ void ProtocolAnalytics::logEvent(const char* eventId, LogEventParamMap* paramMap */ void ProtocolAnalytics::logTimedEventBegin(const char* eventId) { - NSString* pStrID = [NSString stringWithUTF8String:eventId]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "logTimedEventBegin:", pStrID); + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + NSString* pEvent = [NSString stringWithUTF8String:eventId]; + [curObj logTimedEventBegin:pEvent]; + } } /** @@ -150,8 +147,15 @@ void ProtocolAnalytics::logTimedEventBegin(const char* eventId) */ void ProtocolAnalytics::logTimedEventEnd(const char* eventId) { - NSString* pStrID = [NSString stringWithUTF8String:eventId]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "logTimedEventEnd:", pStrID); + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + NSString* pEvent = [NSString stringWithUTF8String:eventId]; + [curObj logTimedEventEnd:pEvent]; + } } /** @@ -160,27 +164,14 @@ void ProtocolAnalytics::logTimedEventEnd(const char* eventId) */ void ProtocolAnalytics::setCaptureUncaughtException(bool enabled) { - NSNumber* bEnable = [NSNumber numberWithBool:enabled]; - PluginUtilsIOS::callOCFunctionWithName_Object(this, "setCaptureUncaughtException:", bEnable); -} - -const char* ProtocolAnalytics::getSDKVersion() -{ - const char* pRet = ""; - - do { - PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); - if (! pData) break; - - id pOCObj = pData->obj; - SEL selector = NSSelectorFromString(@"getSDKVersion"); - if ([pOCObj respondsToSelector:selector]) { - NSString* strRet = [pOCObj performSelector:selector]; - pRet = [strRet UTF8String]; - } - } while (0); - - return pRet; + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceAnalytics)]) { + NSObject* curObj = ocObj; + [curObj setCaptureUncaughtException:enabled]; + } } }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/ProtocolIAP.mm b/plugin/protocols/platform/ios/ProtocolIAP.mm index d142c880c0..e3680b273d 100644 --- a/plugin/protocols/platform/ios/ProtocolIAP.mm +++ b/plugin/protocols/platform/ios/ProtocolIAP.mm @@ -26,7 +26,7 @@ #import "InterfaceIAP.h" namespace cocos2d { namespace plugin { - + bool ProtocolIAP::m_bPaying = false; ProtocolIAP::ProtocolIAP() @@ -39,17 +39,59 @@ ProtocolIAP::~ProtocolIAP() PluginUtilsIOS::erasePluginOCData(this); } -bool ProtocolIAP::init() -{ - return true; -} - void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo) { + if (devInfo.empty()) + { + PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName()); + return; + } + else + { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceIAP)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo); + [curObj configDeveloperInfo:pDict]; + } + } } void ProtocolIAP::payForProduct(TProductInfo info) { + if (m_bPaying) + { + PluginUtilsIOS::outputLog("Now is paying"); + return; + } + + if (info.empty()) + { + if (NULL != m_pListener) + { + onPayResult(kPayFail, "Product info error"); + } + PluginUtilsIOS::outputLog("The product info is empty for %s!", this->getPluginName()); + return; + } + else + { + m_bPaying = true; + m_curInfo = info; + + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceIAP)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(&info); + [curObj payForProduct:dict]; + } + } } void ProtocolIAP::setResultListener(PayResultListener* pListener) @@ -64,17 +106,13 @@ void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg) { m_pListener->onPayResult(ret, msg, m_curInfo); } + else + { + PluginUtilsIOS::outputLog("Pay result listener of %s is null!", this->getPluginName()); + } m_curInfo.clear(); -} - -const char* ProtocolIAP::getSDKVersion() -{ - return "Subclass should override this interface"; -} - -void ProtocolIAP::setDebugMode(bool debug) -{ + PluginUtilsIOS::outputLog("Pay result of %s is : %d(%s)", this->getPluginName(), (int) ret, msg); } }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/ProtocolSocial.mm b/plugin/protocols/platform/ios/ProtocolSocial.mm new file mode 100755 index 0000000000..0c5d559d4f --- /dev/null +++ b/plugin/protocols/platform/ios/ProtocolSocial.mm @@ -0,0 +1,103 @@ +/**************************************************************************** +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. +****************************************************************************/ +#include "ProtocolSocial.h" +#include "PluginUtilsIOS.h" +#import "InterfaceSocial.h" + +namespace cocos2d { namespace plugin { + +ProtocolSocial::ProtocolSocial() +: m_pListener(NULL) +{ +} + +ProtocolSocial::~ProtocolSocial() +{ +} + +void ProtocolSocial::configDeveloperInfo(TSocialDeveloperInfo devInfo) +{ + if (devInfo.empty()) + { + PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName()); + return; + } + else + { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo); + [curObj configDeveloperInfo:pDict]; + } + } +} + +void ProtocolSocial::share(TShareInfo info) +{ + if (info.empty()) + { + if (NULL != m_pListener) + { + onShareResult(kShareFail, "Share info error"); + } + PluginUtilsIOS::outputLog("The Share info of %s is empty!", this->getPluginName()); + return; + } + else + { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + assert(pData != NULL); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfaceSocial)]) { + NSObject* curObj = ocObj; + NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&info); + [curObj share:pDict]; + } + } +} + +void ProtocolSocial::setResultListener(ShareResultListener* pListener) +{ + m_pListener = pListener; +} + +void ProtocolSocial::onShareResult(ShareResultCode ret, const char* msg) +{ + if (m_pListener) + { + m_pListener->onShareResult(ret, msg); + } + else + { + PluginUtilsIOS::outputLog("Share result listener of %s is null!", this->getPluginName()); + } + PluginUtilsIOS::outputLog("Share result of %s is : %d(%s)", this->getPluginName(), (int) ret, msg); +} + +}} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/proj.android/jni/Android.mk b/plugin/protocols/proj.android/jni/Android.mk index 5e82597a05..4bc000a7bd 100755 --- a/plugin/protocols/proj.android/jni/Android.mk +++ b/plugin/protocols/proj.android/jni/Android.mk @@ -8,15 +8,17 @@ LOCAL_MODULE_FILENAME := libPluginProtocolStatic LOCAL_SRC_FILES :=\ $(addprefix ../../platform/android/, \ + PluginFactory.cpp \ PluginJniHelper.cpp \ PluginUtils.cpp \ + PluginProtocol.cpp \ ProtocolAnalytics.cpp \ ProtocolIAP.cpp \ ProtocolAds.cpp \ ProtocolSocial.cpp \ ) \ ../../PluginManager.cpp \ -../../RegisterPlugin.cpp \ +../../PluginParam.cpp LOCAL_CFLAGS := -Wno-psabi LOCAL_EXPORT_CFLAGS := -Wno-psabi diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java new file mode 100644 index 0000000000..42978cad90 --- /dev/null +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java @@ -0,0 +1,114 @@ +/**************************************************************************** +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 android.view.Gravity; +import android.view.View; +import android.view.WindowManager; + +public class AdsWrapper { + + public static final int RESULT_CODE_AdsReceived = 0; // The ad is received + public static final int RESULT_CODE_FullScreenViewShown = 1; // The full screen advertisement shown + public static final int RESULT_CODE_FullScreenViewDismissed = 2; // The full screen advertisement dismissed + public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed + public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed + public static final int RESULT_CODE_NetworkError = 5; // Network error + public static final int RESULT_CODE_UnknownError = 6; // Unknown error + + public static final int ADS_TYPE_BANNER = 0; + public static final int ADS_TYPE_FULL_SCREEN = 1; + + public static final int POS_CENTER = 0; + public static final int POS_TOP = 1; + public static final int POS_TOP_LEFT = 2; + public static final int POS_TOP_RIGHT = 3; + public static final int POS_BOTTOM = 4; + public static final int POS_BOTTOM_LEFT = 5; + public static final int POS_BOTTOM_RIGHT = 6; + + public static void addAdView(WindowManager mWm, View adView, int pos) { + WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(); + mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; + mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; + mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; + mLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + + switch (pos) { + case POS_CENTER: + mLayoutParams.gravity = Gravity.CENTER; + break; + case POS_TOP: + mLayoutParams.gravity = Gravity.TOP; + break; + case POS_TOP_LEFT: + mLayoutParams.gravity = Gravity.TOP | Gravity.LEFT; + break; + case POS_TOP_RIGHT: + mLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT; + break; + case POS_BOTTOM: + mLayoutParams.gravity = Gravity.BOTTOM; + break; + case POS_BOTTOM_LEFT: + mLayoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; + break; + case POS_BOTTOM_RIGHT: + mLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; + break; + default: + break; + } + mWm.addView(adView, mLayoutParams); + } + + public static void onAdsResult(InterfaceAds adapter, int code, String msg) { + final int curCode = code; + final String curMsg = msg; + final InterfaceAds curObj = adapter; + PluginWrapper.runOnGLThread(new Runnable(){ + @Override + public void run() { + String name = curObj.getClass().getName(); + name = name.replace('.', '/'); + AdsWrapper.nativeOnAdsResult(name, curCode, curMsg); + } + }); + } + private native static void nativeOnAdsResult(String className, int code, String msg); + + public static void onPlayerGetPoints(InterfaceAds adapter, int points) { + final int curPoints = points; + final InterfaceAds curAdapter = adapter; + PluginWrapper.runOnGLThread(new Runnable(){ + @Override + public void run() { + String name = curAdapter.getClass().getName(); + name = name.replace('.', '/'); + AdsWrapper.nativeOnPlayerGetPoints(name, curPoints); + } + }); + } + private native static void nativeOnPlayerGetPoints(String className, int points); +} diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java new file mode 100644 index 0000000000..a26c437c18 --- /dev/null +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java @@ -0,0 +1,46 @@ +/**************************************************************************** +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; + +public class IAPWrapper { + public static final int PAYRESULT_SUCCESS = 0; + public static final int PAYRESULT_FAIL = 1; + public static final int PAYRESULT_CANCEL = 2; + public static final int PAYRESULT_TIMEOUT = 3; + + public static void onPayResult(InterfaceIAP obj, int ret, String msg) { + final int curRet = ret; + final String curMsg = msg; + final InterfaceIAP curObj = obj; + PluginWrapper.runOnGLThread(new Runnable() { + @Override + public void run() { + String name = curObj.getClass().getName(); + name = name.replace('.', '/'); + nativeOnPayResult(name, curRet, curMsg); + } + }); + } + private static native void nativeOnPayResult(String className, int ret, String msg); +} diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java index 3842c6311f..6d7f85f1f9 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java @@ -25,101 +25,15 @@ package org.cocos2dx.plugin; import java.util.Hashtable; -import android.view.Gravity; -import android.view.View; -import android.view.WindowManager; +public interface InterfaceAds { -public class InterfaceAds { + public final int PluginType = 1; - public static final int RESULT_CODE_AdsReceived = 0; // The ad is received - public static final int RESULT_CODE_FullScreenViewShown = 1; // The full screen advertisement shown - public static final int RESULT_CODE_FullScreenViewDismissed = 2; // The full screen advertisement dismissed - public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed - public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed - public static final int RESULT_CODE_NetworkError = 5; // Network error - public static final int RESULT_CODE_UnknownError = 6; // Unknown error - - public static final int ADS_TYPE_BANNER = 0; - public static final int ADS_TYPE_FULL_SCREEN = 1; - - public static final int POS_CENTER = 0; - public static final int POS_TOP = 1; - public static final int POS_TOP_LEFT = 2; - public static final int POS_TOP_RIGHT = 3; - public static final int POS_BOTTOM = 4; - public static final int POS_BOTTOM_LEFT = 5; - public static final int POS_BOTTOM_RIGHT = 6; - - public interface AdsAdapter { - public void configDeveloperInfo(Hashtable devInfo); - public void showAds(int type, int sizeEnum, int pos); - public void hideAds(int type); - public void spendPoints(int points); - public void setDebugMode(boolean debug); - public String getSDKVersion(); - } - - public static void addAdView(WindowManager mWm, View adView, int pos) { - WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(); - mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; - mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; - mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; - mLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; - - switch (pos) { - case POS_CENTER: - mLayoutParams.gravity = Gravity.CENTER; - break; - case POS_TOP: - mLayoutParams.gravity = Gravity.TOP; - break; - case POS_TOP_LEFT: - mLayoutParams.gravity = Gravity.TOP | Gravity.LEFT; - break; - case POS_TOP_RIGHT: - mLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT; - break; - case POS_BOTTOM: - mLayoutParams.gravity = Gravity.BOTTOM; - break; - case POS_BOTTOM_LEFT: - mLayoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; - break; - case POS_BOTTOM_RIGHT: - mLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; - break; - default: - break; - } - mWm.addView(adView, mLayoutParams); - } - - public static void onAdsResult(AdsAdapter adapter, int code, String msg) { - final int curCode = code; - final String curMsg = msg; - final AdsAdapter curObj = adapter; - PluginWrapper.runOnGLThread(new Runnable(){ - @Override - public void run() { - String name = curObj.getClass().getName(); - name = name.replace('.', '/'); - InterfaceAds.nativeOnAdsResult(name, curCode, curMsg); - } - }); - } - private native static void nativeOnAdsResult(String className, int code, String msg); - - public static void onPlayerGetPoints(AdsAdapter adapter, int points) { - final int curPoints = points; - final AdsAdapter curAdapter = adapter; - PluginWrapper.runOnGLThread(new Runnable(){ - @Override - public void run() { - String name = curAdapter.getClass().getName(); - name = name.replace('.', '/'); - InterfaceAds.nativeOnPlayerGetPoints(name, curPoints); - } - }); - } - private native static void nativeOnPlayerGetPoints(String className, int points); + public void configDeveloperInfo(Hashtable devInfo); + public void showAds(int type, int sizeEnum, int pos); + public void hideAds(int type); + public void spendPoints(int points); + public void setDebugMode(boolean debug); + public String getSDKVersion(); + public String getPluginVersion(); } diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAnalytics.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAnalytics.java index 9135cd8519..84aa078449 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAnalytics.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAnalytics.java @@ -27,6 +27,8 @@ import java.util.Hashtable; public interface InterfaceAnalytics { + public final int PluginType = 2; + public void startSession(String appKey); public void stopSession(); public void setSessionContinueMillis(int millis); @@ -38,4 +40,5 @@ public interface InterfaceAnalytics { public void logTimedEventBegin(String eventId); public void logTimedEventEnd(String eventId); public String getSDKVersion(); + public String getPluginVersion(); } diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceIAP.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceIAP.java index 340abdc74c..d576287cf2 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceIAP.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceIAP.java @@ -25,31 +25,12 @@ package org.cocos2dx.plugin; import java.util.Hashtable; -public class InterfaceIAP { - public static final int PAYRESULT_SUCCESS = 0; - public static final int PAYRESULT_FAIL = 1; - public static final int PAYRESULT_CANCEL = 2; - public static final int PAYRESULT_TIMEOUT = 3; +public interface InterfaceIAP { + public final int PluginType = 3; - public interface IAPAdapter { - public void configDeveloperInfo(Hashtable cpInfo); - public void payForProduct(Hashtable cpInfo); - public void setDebugMode(boolean debug); - public String getSDKVersion(); - } - - public static void onPayResult(IAPAdapter obj, int ret, String msg) { - final int curRet = ret; - final String curMsg = msg; - final IAPAdapter curObj = obj; - PluginWrapper.runOnGLThread(new Runnable() { - @Override - public void run() { - String name = curObj.getClass().getName(); - name = name.replace('.', '/'); - nativeOnPayResult(name, curRet, curMsg); - } - }); - } - private static native void nativeOnPayResult(String className, int ret, String msg); + public void configDeveloperInfo(Hashtable cpInfo); + public void payForProduct(Hashtable cpInfo); + public void setDebugMode(boolean debug); + public String getSDKVersion(); + public String getPluginVersion(); } diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceSocial.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceSocial.java index 90147ffc6d..4066a0be9e 100755 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceSocial.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceSocial.java @@ -25,31 +25,12 @@ package org.cocos2dx.plugin; import java.util.Hashtable; -public class InterfaceSocial { - public static final int SHARERESULT_SUCCESS = 0; - public static final int SHARERESULT_FAIL = 1; - public static final int SHARERESULT_CANCEL = 2; - public static final int SHARERESULT_TIMEOUT = 3; +public interface InterfaceSocial { + public final int PluginType = 4; - public interface ShareAdapter { - public void configDeveloperInfo(Hashtable cpInfo); - public void share(Hashtable cpInfo); - public void setDebugMode(boolean debug); - public String getSDKVersion(); - } - - public static void onShareResult(ShareAdapter obj, int ret, String msg) { - final int curRet = ret; - final String curMsg = msg; - final ShareAdapter curAdapter = obj; - PluginWrapper.runOnGLThread(new Runnable() { - @Override - public void run() { - String name = curAdapter.getClass().getName(); - name = name.replace('.', '/'); - nativeOnShareResult(name, curRet, curMsg); - } - }); - } - private static native void nativeOnShareResult(String className, int ret, String msg); + public void configDeveloperInfo(Hashtable cpInfo); + public void share(Hashtable cpInfo); + public void setDebugMode(boolean debug); + public String getSDKVersion(); + public String getPluginVersion(); } diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/PluginWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/PluginWrapper.java index 3583870a19..d736d4aeeb 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/PluginWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/PluginWrapper.java @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.plugin; +import java.lang.reflect.Field; + import android.content.Context; import android.opengl.GLSurfaceView; import android.os.Handler; @@ -30,9 +32,7 @@ import android.util.Log; public class PluginWrapper { - - public static native void nativeInitPlugin(Object instance, String className); - + protected static Context sContext = null; protected static GLSurfaceView sGLSurfaceView = null; protected static Handler sMainThreadHandler = null; @@ -50,33 +50,47 @@ public class PluginWrapper { sGLSurfaceView = value; } - protected static boolean initPlugin(String classFullName) + protected static Object initPlugin(String classFullName) { Log.i(TAG, "class name : ----" + classFullName + "----"); Class c = null; - try { - c = Class.forName(classFullName); + try { + String fullName = classFullName.replace('/', '.'); + c = Class.forName(fullName); } catch (ClassNotFoundException e) { Log.e(TAG, "Class " + classFullName + " not found."); e.printStackTrace(); - return false; - } + return null; + } try { Context ctx = getContext(); if (ctx != null) { Object o = c.getDeclaredConstructor(Context.class).newInstance(ctx); - PluginWrapper.nativeInitPlugin(o, classFullName.replace('.', '/')); - return true; + return o; } else { Log.e(TAG, "Plugin " + classFullName + " wasn't initialized."); } } catch (Exception e) { e.printStackTrace(); } - return false; + return null; } - + + protected static int getPluginType(Object obj) { + int nRet = -1; + try + { + Field filedID = obj.getClass().getField("PluginType"); + Integer nObj = (Integer) filedID.get(obj); + nRet = nObj.intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return nRet; + } + public static Context getContext() { return sContext; } diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/SocialWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/SocialWrapper.java new file mode 100755 index 0000000000..76de053aba --- /dev/null +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/SocialWrapper.java @@ -0,0 +1,46 @@ +/**************************************************************************** +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; + +public class SocialWrapper { + public static final int SHARERESULT_SUCCESS = 0; + public static final int SHARERESULT_FAIL = 1; + public static final int SHARERESULT_CANCEL = 2; + public static final int SHARERESULT_TIMEOUT = 3; + + public static void onShareResult(InterfaceSocial obj, int ret, String msg) { + final int curRet = ret; + final String curMsg = msg; + final InterfaceSocial curAdapter = obj; + PluginWrapper.runOnGLThread(new Runnable() { + @Override + public void run() { + String name = curAdapter.getClass().getName(); + name = name.replace('.', '/'); + nativeOnShareResult(name, curRet, curMsg); + } + }); + } + private static native void nativeOnShareResult(String className, int ret, String msg); +} diff --git a/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj b/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj index 289b40e67c..1a124f8ca6 100644 --- a/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj +++ b/plugin/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj @@ -9,12 +9,15 @@ /* Begin PBXBuildFile section */ FA09A325168ADBC2008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A324168ADBC2008C1C7B /* Foundation.framework */; }; FA09A33E168ADC1F008C1C7B /* PluginManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */; }; - FA09A33F168ADC1F008C1C7B /* RegisterPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */; }; FA8CC1E6173754CF00464206 /* PluginUtilsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */; }; FA8CC2041737A3CE00464206 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8CC2031737A3CE00464206 /* CoreFoundation.framework */; }; FA8CC208173894F000464206 /* ProtocolAds.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC205173894F000464206 /* ProtocolAds.mm */; }; FA8CC209173894F000464206 /* ProtocolAnalytics.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC206173894F000464206 /* ProtocolAnalytics.mm */; }; FA8CC20A173894F000464206 /* ProtocolIAP.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC207173894F000464206 /* ProtocolIAP.mm */; }; + FAB6DF961755D7E500C90D89 /* PluginParam.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF951755D7E500C90D89 /* PluginParam.cpp */; }; + FAB6DF981755D82F00C90D89 /* PluginFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF971755D82F00C90D89 /* PluginFactory.mm */; }; + FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF991755D93600C90D89 /* PluginProtocol.mm */; }; + FAB6DFD31756EA4D00C90D89 /* ProtocolSocial.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DFD21756EA4D00C90D89 /* ProtocolSocial.mm */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -36,9 +39,7 @@ FA09A338168ADC05008C1C7B /* PluginProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProtocol.h; sourceTree = ""; }; FA09A339168ADC05008C1C7B /* ProtocolAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolAnalytics.h; sourceTree = ""; }; FA09A33A168ADC05008C1C7B /* ProtocolIAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolIAP.h; sourceTree = ""; }; - FA09A33B168ADC05008C1C7B /* RegisterPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterPlugin.h; sourceTree = ""; }; FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginManager.cpp; path = ../PluginManager.cpp; sourceTree = ""; }; - FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterPlugin.cpp; path = ../RegisterPlugin.cpp; sourceTree = ""; }; FA4E3033172BD02800A3E673 /* ProtocolSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolSocial.h; sourceTree = ""; }; FA7C6C971724E4DD008A0ECC /* ProtocolAds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolAds.h; sourceTree = ""; }; FA8CC1E4173754CF00464206 /* PluginUtilsIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginUtilsIOS.h; sourceTree = ""; }; @@ -51,6 +52,13 @@ FA8CC21C1739E86E00464206 /* InterfaceAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceAnalytics.h; sourceTree = ""; }; FA8CC21D1739E86E00464206 /* InterfaceIAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceIAP.h; sourceTree = ""; }; FA8CC21E1739E86E00464206 /* InterfaceSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceSocial.h; sourceTree = ""; }; + FAB6DF931755D7D100C90D89 /* PluginFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginFactory.h; sourceTree = ""; }; + FAB6DF941755D7D100C90D89 /* PluginParam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginParam.h; sourceTree = ""; }; + FAB6DF951755D7E500C90D89 /* PluginParam.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginParam.cpp; path = ../PluginParam.cpp; sourceTree = ""; }; + FAB6DF971755D82F00C90D89 /* PluginFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginFactory.mm; sourceTree = ""; }; + FAB6DF991755D93600C90D89 /* PluginProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProtocol.mm; sourceTree = ""; }; + FAB6DFCD1755EF8E00C90D89 /* PluginOCMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginOCMacros.h; sourceTree = ""; }; + FAB6DFD21756EA4D00C90D89 /* ProtocolSocial.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolSocial.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -69,10 +77,10 @@ FA09A316168ADBC2008C1C7B = { isa = PBXGroup; children = ( + FAB6DF951755D7E500C90D89 /* PluginParam.cpp */, FA8CC2031737A3CE00464206 /* CoreFoundation.framework */, FA0CB8B5168D3CC200E36B11 /* ios */, FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */, - FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */, FA09A336168ADC05008C1C7B /* include */, FA09A323168ADBC2008C1C7B /* Frameworks */, FA09A322168ADBC2008C1C7B /* Products */, @@ -98,13 +106,14 @@ FA09A336168ADC05008C1C7B /* include */ = { isa = PBXGroup; children = ( - FA4E3033172BD02800A3E673 /* ProtocolSocial.h */, - FA7C6C971724E4DD008A0ECC /* ProtocolAds.h */, + FAB6DF931755D7D100C90D89 /* PluginFactory.h */, + FAB6DF941755D7D100C90D89 /* PluginParam.h */, FA09A337168ADC05008C1C7B /* PluginManager.h */, FA09A338168ADC05008C1C7B /* PluginProtocol.h */, + FA7C6C971724E4DD008A0ECC /* ProtocolAds.h */, FA09A339168ADC05008C1C7B /* ProtocolAnalytics.h */, FA09A33A168ADC05008C1C7B /* ProtocolIAP.h */, - FA09A33B168ADC05008C1C7B /* RegisterPlugin.h */, + FA4E3033172BD02800A3E673 /* ProtocolSocial.h */, ); name = include; path = ../include; @@ -113,6 +122,9 @@ FA0CB8B5168D3CC200E36B11 /* ios */ = { isa = PBXGroup; children = ( + FAB6DFCD1755EF8E00C90D89 /* PluginOCMacros.h */, + FAB6DF991755D93600C90D89 /* PluginProtocol.mm */, + FAB6DF971755D82F00C90D89 /* PluginFactory.mm */, FA8CC21B1739E86E00464206 /* InterfaceAds.h */, FA8CC21C1739E86E00464206 /* InterfaceAnalytics.h */, FA8CC21D1739E86E00464206 /* InterfaceIAP.h */, @@ -120,6 +132,7 @@ FA8CC205173894F000464206 /* ProtocolAds.mm */, FA8CC206173894F000464206 /* ProtocolAnalytics.mm */, FA8CC207173894F000464206 /* ProtocolIAP.mm */, + FAB6DFD21756EA4D00C90D89 /* ProtocolSocial.mm */, FA8CC1E4173754CF00464206 /* PluginUtilsIOS.h */, FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */, ); @@ -179,11 +192,14 @@ buildActionMask = 2147483647; files = ( FA09A33E168ADC1F008C1C7B /* PluginManager.cpp in Sources */, - FA09A33F168ADC1F008C1C7B /* RegisterPlugin.cpp in Sources */, FA8CC1E6173754CF00464206 /* PluginUtilsIOS.mm in Sources */, FA8CC208173894F000464206 /* ProtocolAds.mm in Sources */, FA8CC209173894F000464206 /* ProtocolAnalytics.mm in Sources */, FA8CC20A173894F000464206 /* ProtocolIAP.mm in Sources */, + FAB6DF961755D7E500C90D89 /* PluginParam.cpp in Sources */, + FAB6DF981755D82F00C90D89 /* PluginFactory.mm in Sources */, + FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */, + FAB6DFD31756EA4D00C90D89 /* ProtocolSocial.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp b/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp index d36d4c02c6..f622c8d36b 100644 --- a/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloAds/Classes/HelloWorldScene.cpp @@ -71,7 +71,7 @@ bool HelloWorld::init() return false; } - m_pAdmob = dynamic_cast(PluginManager::getInstance()->loadPlugin("AdsAdmob")); + m_pAdmob = dynamic_cast(PluginManager::getInstance()->loadPlugin("AdsAdmob")); TAdsDeveloperInfo devInfo; devInfo["AdmobID"] = "a1516fb6b16b12f"; m_pAdmob->configDeveloperInfo(devInfo); @@ -168,7 +168,7 @@ void HelloWorld::testShow(CCObject* pSender) int nSize = 0; if (m_pAds == m_pAdmob) { - nSize = AdsAdmob::kSizeBanner; + nSize = 0; } if (m_pAds) diff --git a/plugin/samples/HelloAds/Classes/HelloWorldScene.h b/plugin/samples/HelloAds/Classes/HelloWorldScene.h index 4d9573712c..19a04807ff 100644 --- a/plugin/samples/HelloAds/Classes/HelloWorldScene.h +++ b/plugin/samples/HelloAds/Classes/HelloWorldScene.h @@ -25,7 +25,7 @@ THE SOFTWARE. #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" -#include "AdsAdmob.h" +#include "ProtocolAds.h" class MyAdsListener : public cocos2d::plugin::AdsListener { @@ -57,7 +57,7 @@ public: CREATE_FUNC(HelloWorld); private: - cocos2d::plugin::AdsAdmob* m_pAdmob; + cocos2d::plugin::ProtocolAds* m_pAdmob; MyAdsListener* m_pListener; cocos2d::CCMenuItemToggle* m_pCaseItem; diff --git a/plugin/samples/HelloAds/proj.android/jni/Android.mk b/plugin/samples/HelloAds/proj.android/jni/Android.mk index a10377440a..49fb10bb3c 100644 --- a/plugin/samples/HelloAds/proj.android/jni/Android.mk +++ b/plugin/samples/HelloAds/proj.android/jni/Android.mk @@ -13,10 +13,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \ -PluginProtocolStatic PluginAdmobStatic +PluginProtocolStatic include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,protocols/android) -$(call import-module,plugins/admob/android) diff --git a/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp b/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp index d964b52fc3..8375de18bb 100644 --- a/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp +++ b/plugin/samples/HelloAnalytics/Classes/AppDelegate.cpp @@ -25,8 +25,7 @@ THE SOFTWARE. #include "cocos2d.h" #include "HelloWorldScene.h" #include "PluginManager.h" -#include "AnalyticsFlurry.h" -#include "AnalyticsUmeng.h" +#include "ProtocolAnalytics.h" using namespace cocos2d::plugin; USING_NS_CC; @@ -91,25 +90,27 @@ bool AppDelegate::applicationDidFinishLaunching() const char* sdkVer = g_pAnalytics->getSDKVersion(); CCLog("SDK version : %s", sdkVer); - AnalyticsUmeng* pUmeng = dynamic_cast(g_pAnalytics); - AnalyticsFlurry* pFlurry = dynamic_cast(g_pAnalytics); - if (pUmeng != NULL) - { - pUmeng->updateOnlineConfig(); - pUmeng->setDefaultReportPolicy(AnalyticsUmeng::REALTIME); - } + g_pAnalytics->callFuncWithParam("updateOnlineConfig", NULL); - if (pFlurry != NULL) - { - pFlurry->setReportLocation(true); - pFlurry->logPageView(); - // const char* sdkVersion = pFlurry->getSDKVersion(); - pFlurry->setVersionName("1.1"); - pFlurry->setAge(20); - pFlurry->setGender(AnalyticsFlurry::MALE); - pFlurry->setUserId("123456"); - pFlurry->setUseHttps(false); - } + PluginParam pParam1(true); + g_pAnalytics->callFuncWithParam("setReportLocation", &pParam1, NULL); + + g_pAnalytics->callFuncWithParam("logPageView", NULL); + + PluginParam pParam2("1.1"); + g_pAnalytics->callFuncWithParam("setVersionName", &pParam2, NULL); + + PluginParam pParam3(20); + g_pAnalytics->callFuncWithParam("setAge", &pParam3, NULL); + + PluginParam pParam4(1); + g_pAnalytics->callFuncWithParam("setGender", &pParam4, NULL); + + PluginParam pParam5("123456"); + g_pAnalytics->callFuncWithParam("setUserId", &pParam5, NULL); + + PluginParam pParam6(false); + g_pAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); diff --git a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp b/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp index df76783ab8..2f24e66294 100644 --- a/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp +++ b/plugin/samples/HelloAnalytics/Classes/HelloWorldScene.cpp @@ -23,8 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "HelloWorldScene.h" #include "PluginManager.h" -#include "AnalyticsFlurry.h" -#include "AnalyticsUmeng.h" +#include "ProtocolAnalytics.h" #include "AppDelegate.h" using namespace cocos2d; @@ -112,7 +111,7 @@ bool HelloWorld::init() } std::string strName = g_pAnalytics->getPluginName(); - std::string strVer = g_pAnalytics->getPluginVersion(); + std::string strVer = g_pAnalytics->getSDKVersion(); char ret[256] = { 0 }; sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); CCLabelTTF* pLabel = CCLabelTTF::create(ret, "Arial", 18, CCSizeMake(size.width, 0), kCCTextAlignmentCenter); @@ -139,8 +138,6 @@ void HelloWorld::reloadPluginMenuCallback(CCObject* pSender) void HelloWorld::eventMenuCallback(CCObject* pSender) { CCMenuItemLabel* pMenuItem = (CCMenuItemLabel*)pSender; - AnalyticsUmeng* pUmeng = dynamic_cast(g_pAnalytics); - AnalyticsFlurry* pFlurry = dynamic_cast(g_pAnalytics); switch (pMenuItem->getTag()) { @@ -160,64 +157,64 @@ void HelloWorld::eventMenuCallback(CCObject* pSender) break; case TAG_LOG_ONLINE_CONFIG: { - if (pUmeng != NULL) - { - CCLog("Online config = %s", pUmeng->getConfigParams("abc")); - } - else - { - CCLog("Now is not using umeng!"); - } + PluginParam param("abc"); + CCLog("Online config = %s", g_pAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL)); } break; case TAG_LOG_EVENT_ID_DURATION: { - if (pUmeng != NULL) - { - pUmeng->logEventWithDuration("book", 12000); - pUmeng->logEventWithDuration("book", 23000, "chapter1"); - LogEventParamMap paramMap; - paramMap.insert(LogEventParamPair("type", "popular")); - paramMap.insert(LogEventParamPair("artist", "JJLin")); - pUmeng->logEventWithDuration("music", 2330000, ¶mMap); - } - else - { - CCLog("Now is not using umeng!"); - } + PluginParam event1("book"); + PluginParam dura1(12000); + g_pAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL); + + PluginParam event2("book"); + PluginParam dura2(12000); + PluginParam label("chapter1"); + g_pAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL); + + PluginParam event3("music"); + PluginParam dura3(2330000); + LogEventParamMap paramMap; + paramMap.insert(LogEventParamPair("type", "popular")); + paramMap.insert(LogEventParamPair("artist", "JJLin")); + PluginParam mapValue(paramMap); + g_pAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL); } break; case TAG_LOG_EVENT_BEGIN: { g_pAnalytics->logTimedEventBegin("music"); + PluginParam event1("music"); + PluginParam label1("one"); + g_pAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL); + + PluginParam event2("music"); + PluginParam label2("flag0"); LogEventParamMap paramMap; paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("artist", "JJLin")); + PluginParam mapValue(paramMap); + g_pAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL); - if (pUmeng != NULL) - { - pUmeng->logTimedEventWithLabelBegin("music", "one"); - pUmeng->logTimedKVEventBegin("music", "flag0", ¶mMap); - } - else if (pFlurry != NULL) - { - pFlurry->logTimedEventBegin("music-kv", ¶mMap); - } + PluginParam event3("music-kv"); + g_pAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL); } break; case TAG_LOG_EVENT_END: { g_pAnalytics->logTimedEventEnd("music"); - if (pUmeng != NULL) - { - pUmeng->logTimedEventWithLabelEnd("music", "one"); - pUmeng->logTimedKVEventEnd("music", "flag0"); - } - else if (pFlurry != NULL) - { - pFlurry->logTimedEventEnd("music-kv"); - } + + PluginParam event1("music"); + PluginParam label1("one"); + g_pAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL); + + PluginParam event2("music"); + PluginParam label2("flag0"); + g_pAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL); + + PluginParam event3("music-kv"); + g_pAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL); } break; case TAG_MAKE_ME_CRASH: diff --git a/plugin/samples/HelloAnalytics/proj.android/.project b/plugin/samples/HelloAnalytics/proj.android/.project index f6032c3714..242b4d396f 100644 --- a/plugin/samples/HelloAnalytics/proj.android/.project +++ b/plugin/samples/HelloAnalytics/proj.android/.project @@ -31,6 +31,11 @@ org.eclipse.jdt.core.javanature + + Classes + 2 + PARENT-1-PROJECT_LOC/Classes + publish 2 diff --git a/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk b/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk index 25eba89294..6940ebe855 100644 --- a/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk +++ b/plugin/samples/HelloAnalytics/proj.android/jni/Android.mk @@ -13,11 +13,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginFlurryStatic PluginUmengStatic PluginProtocolStatic + PluginProtocolStatic include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) \ -$(call import-module,plugins/flurry/android) \ -$(call import-module,plugins/umeng/android) \ $(call import-module,protocols/android) diff --git a/plugin/samples/HelloIAP/Classes/MyPurchase.cpp b/plugin/samples/HelloIAP/Classes/MyPurchase.cpp index 213909a207..49b7ac858d 100644 --- a/plugin/samples/HelloIAP/Classes/MyPurchase.cpp +++ b/plugin/samples/HelloIAP/Classes/MyPurchase.cpp @@ -75,7 +75,7 @@ void MyPurchase::loadIAPPlugin() { // init alipay plugin - s_pAlipay = dynamic_cast(PluginManager::getInstance()->loadPlugin("IAPAlipay")); + s_pAlipay = dynamic_cast(PluginManager::getInstance()->loadPlugin("IAPAlipay")); TIAPDeveloperInfo pAlipayInfo; if (pAlipayInfo.empty()) { @@ -98,7 +98,7 @@ void MyPurchase::loadIAPPlugin() sprintf(msg, "Developer info is empty. PLZ fill your Nd91 info in %s(nearby line %d)", __FILE__, __LINE__); CCMessageBox(msg, "Nd91 Warning"); } - s_pNd91 = dynamic_cast(PluginManager::getInstance()->loadPlugin("IAPNd91")); + s_pNd91 = dynamic_cast(PluginManager::getInstance()->loadPlugin("IAPNd91")); s_pNd91->setDebugMode(true); s_pNd91->configDeveloperInfo(pNdInfo); s_pNd91->setResultListener(s_pRetListener); diff --git a/plugin/samples/HelloIAP/Classes/MyPurchase.h b/plugin/samples/HelloIAP/Classes/MyPurchase.h index df863f009c..a5d2048864 100644 --- a/plugin/samples/HelloIAP/Classes/MyPurchase.h +++ b/plugin/samples/HelloIAP/Classes/MyPurchase.h @@ -24,8 +24,7 @@ THE SOFTWARE. #ifndef __MY_PURCHASE_H__ #define __MY_PURCHASE_H__ -#include "IAPAlipay.h" -#include "IAPNd91.h" +#include "ProtocolIAP.h" class MyPurchaseResult : public cocos2d::plugin::PayResultListener { @@ -55,8 +54,8 @@ private: static MyPurchase* s_pPurchase; - cocos2d::plugin::IAPAlipay* s_pAlipay; - cocos2d::plugin::IAPNd91* s_pNd91; + cocos2d::plugin::ProtocolIAP* s_pAlipay; + cocos2d::plugin::ProtocolIAP* s_pNd91; MyPurchaseResult* s_pRetListener; }; diff --git a/plugin/samples/HelloIAP/proj.android/jni/Android.mk b/plugin/samples/HelloIAP/proj.android/jni/Android.mk index a3eb4d3d13..a51de9683d 100644 --- a/plugin/samples/HelloIAP/proj.android/jni/Android.mk +++ b/plugin/samples/HelloIAP/proj.android/jni/Android.mk @@ -14,13 +14,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginAlipayStatic \ - PluginNd91Static \ PluginProtocolStatic include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) \ -$(call import-module,plugins/alipay/android) \ -$(call import-module,plugins/nd91/android) \ $(call import-module,protocols/android) diff --git a/plugin/samples/HelloSocial/Classes/MySocialManager.cpp b/plugin/samples/HelloSocial/Classes/MySocialManager.cpp index ca138cf4fc..62bea5c815 100755 --- a/plugin/samples/HelloSocial/Classes/MySocialManager.cpp +++ b/plugin/samples/HelloSocial/Classes/MySocialManager.cpp @@ -75,40 +75,46 @@ void MySocialManager::loadSocialPlugin() { // init twitter plugin - s_pTwitter = dynamic_cast(PluginManager::getInstance()->loadPlugin("SocialTwitter")); - TSocialDeveloperInfo pTwitterInfo; - - /* Warning: must set your twiiter dev info here */ - // pTwitterInfo["TwitterKey"] = "your consumerkey"; - // pTwitterInfo["TwitterSecret"] = "your consumersecret"; - - if (pTwitterInfo.empty()) + s_pTwitter = dynamic_cast(PluginManager::getInstance()->loadPlugin("SocialTwitter")); + if (NULL != s_pTwitter) { - char msg[256] = { 0 }; - sprintf(msg, "Developer info is empty. PLZ fill your twitter info in %s(nearby line %d)", __FILE__, __LINE__); - CCMessageBox(msg, "Twitter Warning"); + TSocialDeveloperInfo pTwitterInfo; + + /* Warning: must set your twiiter dev info here */ + // pTwitterInfo["TwitterKey"] = "your consumerkey"; + // pTwitterInfo["TwitterSecret"] = "your consumersecret"; + + if (pTwitterInfo.empty()) + { + char msg[256] = { 0 }; + sprintf(msg, "Developer info is empty. PLZ fill your twitter info in %s(nearby line %d)", __FILE__, __LINE__); + CCMessageBox(msg, "Twitter Warning"); + } + s_pTwitter->setDebugMode(true); + s_pTwitter->configDeveloperInfo(pTwitterInfo); + s_pTwitter->setResultListener(s_pRetListener); } - s_pTwitter->setDebugMode(true); - s_pTwitter->configDeveloperInfo(pTwitterInfo); - s_pTwitter->setResultListener(s_pRetListener); } { - s_pWeibo = dynamic_cast(PluginManager::getInstance()->loadPlugin("SocialWeibo")); - TSocialDeveloperInfo pWeiboInfo; - // pWeiboInfo["WeiboAppKey"] = "your app key"; - // pWeiboInfo["WeiboRedirectUrl"] = "your redirect url"; - - if (pWeiboInfo.empty()) + s_pWeibo = dynamic_cast(PluginManager::getInstance()->loadPlugin("SocialWeibo")); + if (NULL != s_pWeibo) { - char msg[256] = { 0 }; - sprintf(msg, "Developer info is empty. PLZ fill your weibo info in %s(nearby line %d)", __FILE__, __LINE__); - CCMessageBox(msg, "Weibo Warning"); - } + TSocialDeveloperInfo pWeiboInfo; + // pWeiboInfo["WeiboAppKey"] = "your app key"; + // pWeiboInfo["WeiboRedirectUrl"] = "your redirect url"; - s_pWeibo->setDebugMode(true); - s_pWeibo->configDeveloperInfo(pWeiboInfo); - s_pWeibo->setResultListener(s_pRetListener); + if (pWeiboInfo.empty()) + { + char msg[256] = { 0 }; + sprintf(msg, "Developer info is empty. PLZ fill your weibo info in %s(nearby line %d)", __FILE__, __LINE__); + CCMessageBox(msg, "Weibo Warning"); + } + + s_pWeibo->setDebugMode(true); + s_pWeibo->configDeveloperInfo(pWeiboInfo); + s_pWeibo->setResultListener(s_pRetListener); + } } } diff --git a/plugin/samples/HelloSocial/Classes/MySocialManager.h b/plugin/samples/HelloSocial/Classes/MySocialManager.h index 5aa6d72f76..cc647499b3 100755 --- a/plugin/samples/HelloSocial/Classes/MySocialManager.h +++ b/plugin/samples/HelloSocial/Classes/MySocialManager.h @@ -24,8 +24,7 @@ THE SOFTWARE. #ifndef __MY_SOCIAL_MANAGER_H__ #define __MY_SOCIAL_MANAGER_H__ -#include "SocialTwitter.h" -#include "SocialWeibo.h" +#include "ProtocolSocial.h" class MyShareResult : public cocos2d::plugin::ShareResultListener { @@ -55,8 +54,8 @@ private: static MySocialManager* s_pManager; - cocos2d::plugin::SocialTwitter* s_pTwitter; - cocos2d::plugin::SocialWeibo* s_pWeibo; + cocos2d::plugin::ProtocolSocial* s_pTwitter; + cocos2d::plugin::ProtocolSocial* s_pWeibo; MyShareResult* s_pRetListener; }; diff --git a/plugin/samples/HelloSocial/proj.android/jni/Android.mk b/plugin/samples/HelloSocial/proj.android/jni/Android.mk index 820eb3ba00..cf391cb2bf 100755 --- a/plugin/samples/HelloSocial/proj.android/jni/Android.mk +++ b/plugin/samples/HelloSocial/proj.android/jni/Android.mk @@ -14,13 +14,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \ - PluginTwitterStatic \ - PluginProtocolStatic \ - PluginWeiboStatic + PluginProtocolStatic include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) -$(call import-module,plugins/twitter/android) -$(call import-module,plugins/weibo/android) $(call import-module,protocols/android) diff --git a/plugin/tools/publish.sh b/plugin/tools/publish.sh index 8eb12ad8ab..f7d2c72620 100755 --- a/plugin/tools/publish.sh +++ b/plugin/tools/publish.sh @@ -29,7 +29,7 @@ echo echo echo Now publish protocols echo --------------------------------- -./toolsForPublish/publishPlugin.sh "protocols" ${TARGET_ROOT} ${PLUGIN_ROOT} +./toolsForPublish/publishPlugin.sh "protocols" ${TARGET_ROOT} ${PLUGIN_ROOT} 1 echo --------------------------------- #publish plugins diff --git a/plugin/tools/toolsForPublish/publishPlugin.sh b/plugin/tools/toolsForPublish/publishPlugin.sh index 27b0140aa4..82878c9646 100755 --- a/plugin/tools/toolsForPublish/publishPlugin.sh +++ b/plugin/tools/toolsForPublish/publishPlugin.sh @@ -9,10 +9,6 @@ echo android project dir is ${ANDROID_PROJ_DIR} #create directory for plugin mkdir -p ${TARGET_DIR} -#create include directory -mkdir -p ${TARGET_DIR}/include -cp -rf ${PLUGIN_ROOT}/${plugin_name}/include/* ${TARGET_DIR}/include - ############################### # functions used ############################### @@ -84,28 +80,9 @@ if [ -d ${ANDROID_PROJ_DIR}/sdk ]; then cp -rf ${ANDROID_PROJ_DIR}/sdk/*.jar ${TARGET_DIR}/android fi -#copy android include files -ADNROID_SOURCE_DIR=${PLUGIN_ROOT}/${plugin_name}/platform/android -if [ -d ${ADNROID_SOURCE_DIR} ]; then - HAVE_HEADER_FILE=`find ${ADNROID_SOURCE_DIR} -name "*.h"` - if [ -n "${HAVE_HEADER_FILE}" ]; then - cp -rf ${ADNROID_SOURCE_DIR}/*.h "${TARGET_DIR}/android" - fi -fi - -#invoke ndk build for plugin project -if [ -f "${ANDROID_PROJ_DIR}/build_native.sh" ]; then - ./build_native.sh - LIB_FILE="$(getLibraryFileName)" - cp -rf "${ANDROID_PROJ_DIR}/obj/local/armeabi/${LIB_FILE}" "${TARGET_DIR}/android" -fi - -#generate mk file for prebuild -${PLUGIN_ROOT}/tools/toolsForPublish/genPrebuildMK.sh ${ANDROID_PROJ_DIR}/jni/Android.mk ${TARGET_DIR}/android/Android.mk - #copy android depend on project to publish directory -if [ -d "${ADNROID_SOURCE_DIR}/DependProject" ]; then - cp -rf "${ADNROID_SOURCE_DIR}/DependProject" "${TARGET_DIR}/android" +if [ -d "${ANDROID_PROJ_DIR}/DependProject" ]; then + cp -rf "${ANDROID_PROJ_DIR}/DependProject" "${TARGET_DIR}/android" fi #copy ForManifest.xml file to publish directory @@ -123,4 +100,34 @@ if [ -d "${ANDROID_PROJ_DIR}/ForAssets" ]; then cp -rf "${ANDROID_PROJ_DIR}/ForAssets" "${TARGET_DIR}/android" fi +#Build C++ code +BUILD_CPLUSPLUS=$4 +if [ $BUILD_CPLUSPLUS ]; then + + echo "Build C++ code" + + #create include directory + mkdir -p ${TARGET_DIR}/include + cp -rf ${PLUGIN_ROOT}/${plugin_name}/include/* ${TARGET_DIR}/include + + #copy android include files + ADNROID_SOURCE_DIR=${PLUGIN_ROOT}/${plugin_name}/platform/android + if [ -d ${ADNROID_SOURCE_DIR} ]; then + HAVE_HEADER_FILE=`find ${ADNROID_SOURCE_DIR} -name "*.h"` + if [ -n "${HAVE_HEADER_FILE}" ]; then + cp -rf ${ADNROID_SOURCE_DIR}/*.h "${TARGET_DIR}/android" + fi + fi + + #invoke ndk build for plugin project + if [ -f "${ANDROID_PROJ_DIR}/build_native.sh" ]; then + ./build_native.sh + LIB_FILE="$(getLibraryFileName)" + cp -rf "${ANDROID_PROJ_DIR}/obj/local/armeabi/${LIB_FILE}" "${TARGET_DIR}/android" + fi + + #generate mk file for prebuild + ${PLUGIN_ROOT}/tools/toolsForPublish/genPrebuildMK.sh ${ANDROID_PROJ_DIR}/jni/Android.mk ${TARGET_DIR}/android/Android.mk +fi + popd