From 9f61f920179c91830f242552e2a339638960df04 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Mon, 27 May 2013 13:58:31 +0800 Subject: [PATCH] issue #2224 : Modify the implementation of plugin twitter & weibo on android for the new framework of plugin. --- .../plugins/twitter/include/SocialTwitter.h | 76 ------------------ plugin/plugins/twitter/jsb_twitter.ini | 60 -------------- .../platform/android/SocialTwitter.cpp | 78 ------------------- .../twitter/proj.android/build_native.sh | 20 ----- .../twitter/proj.android/jni/Android.mk | 29 ------- .../twitter/proj.android/jni/Application.mk | 7 -- .../org/cocos2dx/plugin/SocialTwitter.java | 22 +++--- plugin/plugins/weibo/include/SocialWeibo.h | 74 ------------------ plugin/plugins/weibo/jsb_weibo.ini | 60 -------------- .../weibo/platform/android/SocialWeibo.cpp | 77 ------------------ .../weibo/proj.android/build_native.sh | 20 ----- .../plugins/weibo/proj.android/jni/Android.mk | 29 ------- .../weibo/proj.android/jni/Application.mk | 7 -- .../src/org/cocos2dx/plugin/SocialWeibo.java | 28 ++++--- plugin/protocols/PluginManager.cpp | 4 + .../platform/android/PluginFactory.cpp | 26 ++++--- .../platform/android/PluginProtocol.cpp | 2 - .../platform/android/PluginUtils.cpp | 4 + .../protocols/platform/android/PluginUtils.h | 4 + .../platform/android/ProtocolAds.cpp | 4 +- .../platform/android/ProtocolIAP.cpp | 2 +- .../platform/android/ProtocolSocial.cpp | 2 +- plugin/protocols/proj.android/jni/Android.mk | 1 + .../src/org/cocos2dx/plugin/AdsWrapper.java | 2 - .../src/org/cocos2dx/plugin/IAPWrapper.java | 2 - .../org/cocos2dx/plugin/PluginWrapper.java | 16 ++++ .../org/cocos2dx/plugin/SocialWrapper.java | 2 - .../HelloSocial/Classes/MySocialManager.cpp | 60 +++++++------- .../HelloSocial/Classes/MySocialManager.h | 7 +- .../HelloSocial/proj.android/jni/Android.mk | 6 +- plugin/tools/publish.sh | 2 +- plugin/tools/toolsForPublish/publishPlugin.sh | 53 +++++++------ 32 files changed, 147 insertions(+), 639 deletions(-) delete mode 100755 plugin/plugins/twitter/include/SocialTwitter.h delete mode 100644 plugin/plugins/twitter/jsb_twitter.ini delete mode 100755 plugin/plugins/twitter/platform/android/SocialTwitter.cpp delete mode 100755 plugin/plugins/twitter/proj.android/build_native.sh delete mode 100755 plugin/plugins/twitter/proj.android/jni/Android.mk delete mode 100755 plugin/plugins/twitter/proj.android/jni/Application.mk delete mode 100755 plugin/plugins/weibo/include/SocialWeibo.h delete mode 100644 plugin/plugins/weibo/jsb_weibo.ini delete mode 100755 plugin/plugins/weibo/platform/android/SocialWeibo.cpp delete mode 100755 plugin/plugins/weibo/proj.android/build_native.sh delete mode 100755 plugin/plugins/weibo/proj.android/jni/Android.mk delete mode 100755 plugin/plugins/weibo/proj.android/jni/Application.mk 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/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/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/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 b4d79d8edd..f39a893ca2 100644 --- a/plugin/protocols/PluginManager.cpp +++ b/plugin/protocols/PluginManager.cpp @@ -77,6 +77,10 @@ PluginProtocol* PluginManager::loadPlugin(const char* name) it->second = PluginFactory::getInstance()->createPlugin(name); } pRet = it->second; + } else + { + pRet = PluginFactory::getInstance()->createPlugin(name); + m_pluginsMap["name"] = pRet; } } while (false); diff --git a/plugin/protocols/platform/android/PluginFactory.cpp b/plugin/protocols/platform/android/PluginFactory.cpp index 09029f1fa9..6b4ba4a89b 100644 --- a/plugin/protocols/platform/android/PluginFactory.cpp +++ b/plugin/protocols/platform/android/PluginFactory.cpp @@ -38,9 +38,7 @@ enum { kPluginSocial, }; -#define ANDROID_PLUGIN_TYPE_FIELD "PluginType" -#define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugins/" -#define BREAK_IF(cond) if(cond) break +#define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugin/" static PluginFactory* s_pFactory = NULL; @@ -91,6 +89,7 @@ PluginProtocol* PluginFactory::createPlugin(const char* name) , "initPlugin" , "(Ljava/lang/String;)Ljava/lang/Object;")) { + PluginUtils::outputLog("PluginFactory", "Can't find method initPlugin in class org.cocos2dx.plugin.PluginWrapper"); break; } @@ -98,13 +97,22 @@ PluginProtocol* PluginFactory::createPlugin(const char* name) jobject jObj = t.env->CallStaticObjectMethod(t.classID, t.methodID, clsName); t.env->DeleteLocalRef(clsName); t.env->DeleteLocalRef(t.classID); - BREAK_IF(jObj == NULL); + if (jObj == NULL) + { + PluginUtils::outputLog("PluginFactory", "Can't find java class %s", jClassName.c_str()); + break; + } - jclass jcls = t.env->FindClass(jClassName.c_str()); - jfieldID fid_Type = t.env->GetFieldID(jcls, ANDROID_PLUGIN_TYPE_FIELD, "I"); - BREAK_IF(fid_Type == NULL); - - int curType = t.env->GetIntField(jObj, fid_Type); + 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) diff --git a/plugin/protocols/platform/android/PluginProtocol.cpp b/plugin/protocols/platform/android/PluginProtocol.cpp index e049e30df8..52983f9f9c 100644 --- a/plugin/protocols/platform/android/PluginProtocol.cpp +++ b/plugin/protocols/platform/android/PluginProtocol.cpp @@ -115,5 +115,3 @@ void PluginProtocol::callFuncWithParam(const char* funcName, PluginParam* param) } }} //namespace cocos2d { namespace plugin { - -#endif /* __CCX_IPLUGIN_H__ */ diff --git a/plugin/protocols/platform/android/PluginUtils.cpp b/plugin/protocols/platform/android/PluginUtils.cpp index 64068b0a9a..6437e9ff01 100644 --- a/plugin/protocols/platform/android/PluginUtils.cpp +++ b/plugin/protocols/platform/android/PluginUtils.cpp @@ -98,6 +98,10 @@ PluginJavaData* PluginUtils::getPluginJavaData(PluginProtocol* pKeyObj) ret = it->second; } + if (NULL != ret) + { + outputLog("PluginUtils", "get plugin java data : %s, %p", ret->jclassName.c_str(), ret->jobj); + } return ret; } diff --git a/plugin/protocols/platform/android/PluginUtils.h b/plugin/protocols/platform/android/PluginUtils.h index 9f6d97ec4a..db9c9ebf99 100644 --- a/plugin/protocols/platform/android/PluginUtils.h +++ b/plugin/protocols/platform/android/PluginUtils.h @@ -56,6 +56,8 @@ public: return_if_fails(funcName != NULL && strlen(funcName) > 0); return_if_fails(paramCode != NULL && strlen(paramCode) > 0); PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); + return_if_fails(pData != NULL); + PluginJniMethodInfo t; if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() @@ -71,6 +73,8 @@ public: { return_if_fails(funcName != NULL && strlen(funcName) > 0); PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); + return_if_fails(pData != NULL); + PluginJniMethodInfo t; if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() diff --git a/plugin/protocols/platform/android/ProtocolAds.cpp b/plugin/protocols/platform/android/ProtocolAds.cpp index 2e03bd444f..65b859852c 100644 --- a/plugin/protocols/platform/android/ProtocolAds.cpp +++ b/plugin/protocols/platform/android/ProtocolAds.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. 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); @@ -46,7 +46,7 @@ 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); PluginUtils::outputLog("ProtocolAds", "nativeOnPlayerGetPoints(), Get plugin ptr : %p", pPlugin); diff --git a/plugin/protocols/platform/android/ProtocolIAP.cpp b/plugin/protocols/platform/android/ProtocolIAP.cpp index fd19cde31a..b12fb1e9c3 100644 --- a/plugin/protocols/platform/android/ProtocolIAP.cpp +++ b/plugin/protocols/platform/android/ProtocolIAP.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. 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); diff --git a/plugin/protocols/platform/android/ProtocolSocial.cpp b/plugin/protocols/platform/android/ProtocolSocial.cpp index 08e3bdd6c6..fab901c89f 100755 --- a/plugin/protocols/platform/android/ProtocolSocial.cpp +++ b/plugin/protocols/platform/android/ProtocolSocial.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. 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); diff --git a/plugin/protocols/proj.android/jni/Android.mk b/plugin/protocols/proj.android/jni/Android.mk index c503f7dc55..4bc000a7bd 100755 --- a/plugin/protocols/proj.android/jni/Android.mk +++ b/plugin/protocols/proj.android/jni/Android.mk @@ -11,6 +11,7 @@ $(addprefix ../../platform/android/, \ PluginFactory.cpp \ PluginJniHelper.cpp \ PluginUtils.cpp \ + PluginProtocol.cpp \ ProtocolAnalytics.cpp \ ProtocolIAP.cpp \ ProtocolAds.cpp \ diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java index 65499853d6..42978cad90 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java @@ -23,8 +23,6 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.plugin; -import java.util.Hashtable; - import android.view.Gravity; import android.view.View; import android.view.WindowManager; diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java index 5e00194ef9..a26c437c18 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/IAPWrapper.java @@ -23,8 +23,6 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.plugin; -import java.util.Hashtable; - public class IAPWrapper { public static final int PAYRESULT_SUCCESS = 0; public static final int PAYRESULT_FAIL = 1; 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 749b41b282..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; @@ -75,6 +77,20 @@ public class PluginWrapper { 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 index c6ab687524..76de053aba 100755 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/SocialWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/SocialWrapper.java @@ -23,8 +23,6 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.plugin; -import java.util.Hashtable; - public class SocialWrapper { public static final int SHARERESULT_SUCCESS = 0; public static final int SHARERESULT_FAIL = 1; 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..2ec88a16e6 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,25 +80,6 @@ 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" @@ -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