This commit is contained in:
Pranav Tekchand 2013-04-30 21:06:18 +05:30
commit 0a996804fa
272 changed files with 20982 additions and 4934 deletions

View File

@ -12,6 +12,9 @@ Developers:
Rolando Abarca
Javascript Binding and testjs
rodrigogolive
Fix broke linux build
kdejongh
Fix for spaces at the beginning of wrapped lines on Android
@ -90,6 +93,7 @@ Developers:
Touch priority can't be set to the value specified by a call to CCMenu::setTouchPriority(int).
CCTableView crashes if a CCTableViewDelegate is not provided.
Fixing a bug that _realOpacity isn't assigned in CCLayerColor::initWithColor.
CCScrollView TouchPriority Fix
Weeds (Andre Rudlaff)
Used fontconfig to enhance font rendering on linux.
@ -101,6 +105,7 @@ Developers:
Fixed potential crash in CCScheduler::removeHashElement.
Fixed potential crash in CCSaxParser.
Added kResolutionFixedHeight and kResolutionFixedWidth resolution policy.
Use pthread mutex and condition variable instead of pthred semaphore to load image asynchronizely.
Nat Weiss (iphonegamekit.com)
author of Mac port

View File

@ -1,3 +1,87 @@
cocos2d-2.1rc0-x-2.1.3 @May.01 2013
[all platforms]
Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project
Bug #1860: fix a bug that onNodeLoaded will be called twice if ccb was added as a CCBFile
Bug #1862: fix a bug that CCScrollView::setContainer may cause dangling pointer when NULL is passed into
Bug #1876: fix a bug that CCScale9Sprite::setColor() & setOpacity() are broken
Bug #1935: fix a bug that use "==" for float comparison of CCPoint and CCSize
Bug #1937: fix a bug that CCControl's touch priority is not set correctly, m_nDefaultTouchPriority is never used
Bug #1943: added some missing function for setting integer shader uniforms in CCGLProgram
Bug #1999: allowing to set fontName and fontSize separately for CCEditBox
Bug #2003: fix a potential crash in CCScheduler::removeHashElement()
Bug #2030: fix a bug that scissor rectangle in nested CCScrollView is wrong
Bug #2031: make CCFileUtils::createXXXXWithContentsOfFile() support relative path
Bug #2035: fix a potential crash in CCSaxParser
Bug #2037: fix a wrong logic in CCArray::initWithObjects()
Bug #2040: get scale property from sub-ccb node may trigger an assert
Bug #2054: fix a bug that anchorPoint property of CCScale9Sprite doesn't work in CCBReader
Bug #2055: enable easy switching between Box2D and chipmunk
Bug #2058: properly resets the tile's Y flipping
Bug #2061: fix a bug that wrong type of argument signature is used in setAccelerometerIntervalJNI function
Bug #2073: fix a memory leak in CCUserDefault
Bug #2080: fix a bug that _realOpacity isn't assigned in CCLayerColor::initWithColor
Feature #2001: add CCRemoveSelf Action
Feature #2048: support variable cell sizes in CCTableView
Feature #2065: adding kResolutionFixedHeight and kResolutionFixedWidth resolution policy
Feature #2068: adding a secureTextEntry property to CCTextFieldTTF
Feature #2069: adding new macro CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK to CCBMemberVariableAssigner.h
Feature #2075: support spine editor
Feature #2076: adding a method CCBReader::setResolutionScale for setting resolution scale manually
Refactor #1592: updating UTHASH to v1.9.8
Refactor #2042: remove libxml2
Refactor #2097: use pthread mutex and condition variable instead of pthread semaphore to load image asynchronizely
[android]
Bug #1996: adding missing JNIEXPORT / JNICALL declarations
Bug #2028: fix a bug taht application can not run correctly on Android simulator
Bug #2045: some small fixes to CocosPlayer
Bug #2062: fix for spaces at the beginning of wrapped lines
Bug #2083: fix a bug that Bytecode of LuaJIT can't work on android
Refactor #1613: not reload resources when coming from background on Android
Refactor #1861: CocosPlayer Android update
Refactor #1904: strip libcurl.a on x86 architecture
Refactor #2027: reduce function call in nativeInitBitmapDC to improve performance
Refactor #2047: clean up linked libraries for android
[iOS]
Bug #1863: fix a bug that CCUserDefault on iOS may not save immediately
Feature #2096: adding Cocosplayer for iOS and bug fixes
[linux]
Bug #1932: fix a bug that font rendering crashed for certain fonts
Bug #2036: correct passed buffer size to readlink
Bug #2044: link libpthread and libGL
Bug #2046: strip newlines from log message and fixing linux library location
Bug #2052: fix a bug that [-Werror=array-bounds] error appears when compiling Box2dTestBed
Feature #2032: Linux OpenAL support
Refactor #2000: improve font rendering performance for linux platform
Refactor #2053: set writable path to "<user's home>/.config/<app name>"
[mac]
Bug #2051: fix a bug that TestCpp/ExtensionsTest/CocosbuilderTest crashes under x86_64 target
Feature #1856: adding 64bit target for Mac project
[javascript binding]
Bug #1855: fix a bug that std_string_to_jsval generates messy js string when passed a non-ascii UTF8 std::string
Bug #2057: adding response for back and menu keypad event for Android
Bug #2059: fix a bug that cc.FileUtils.getInstance().getStringFromFile(filename) doesn't return a whole string
Bug #2071: fix a bug that cc.TMXLayer.getTiles() can't work
Feature #1841: find a way to obfuscate javascript code on the top of JSB
Feature #1936: adding OpenGL Bindings to Javascript
Feature #2043: upgrading SpiderMonkey to Firefox20.0
Feature #2060: support for cc.FileUtils.getInstance().getByteArrayFromFile(filename)
Feature #2064: exposing cc.Node.nodeTo***Transform to JS
Refactor #1944: subclass of cc.Sprite,cc.Layer... doesn't need cc.associateWithNative anymore
[lua binding]
Feature #1814: add menutest
Feature #1941: add TileMapTest
Feature #1942: add LayerTest
Feature #1945: use CCLOG to implement print() function
Feature #1993: add ParallaxTest
Feature #1994: add ActionManagerTest
Feature #1997: add IntervalTest
Feature #1998: add SceneTest
Feature #2002: add Texture2dTest, RenderTexture, ZwoptexTest, FontTest, CocosDenshionTest and EffectsAdvancedTest
Feature #2004: add UserDefaultTest
Feature #2005: add CurrentLanguageTest
Refactor #1847: use luajit
Refactor #2084: unify the method of loading lua files on all platforms
cocos2d-2.1rc0-x-2.1.2 @Mar.20 2013
[all platforms]
Bug #1529: use NSUserDefaults on iOS and SharedPreferences on Android implement CCUserDefault

View File

@ -124,7 +124,7 @@
<tool id="com.qnx.qcc.tool.compiler.2055720937" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compiler.shared.300244130" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.optlevel.1571383965" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compiler.security.1372664386" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1372664386" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.413789958" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -200,7 +200,7 @@
<option id="com.qnx.qcc.option.compiler.shared.657775440" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.104541528" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.1160378025" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1414017107" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1414017107" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.2021691363" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -279,7 +279,7 @@
<option id="com.qnx.qcc.option.compiler.shared.681217815" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.757028752" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.751288313" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1285172306" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1285172306" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1184848882" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -433,7 +433,7 @@
<option id="com.qnx.qcc.option.compiler.shared.1389473150" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.2043094590" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.1074881151" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.101529550" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.101529550" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.2135233180" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -511,7 +511,7 @@
<option id="com.qnx.qcc.option.compiler.shared.1502035671" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.1133385028" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.1003392028" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.994172716" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.994172716" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1430098685" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>

View File

@ -313,7 +313,7 @@ CCAction* CCActionManager::getActionByTag(unsigned int tag, CCObject *pTarget)
}
}
}
CCLOG("cocos2d : getActionByTag: Action not found");
CCLOG("cocos2d : getActionByTag(tag = %d): Action not found", tag);
}
else
{

View File

@ -662,7 +662,7 @@ void CCNode::removeChildByTag(int tag, bool cleanup)
if (child == NULL)
{
CCLOG("cocos2d: removeChildByTag: child not found!");
CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag);
}
else
{

View File

@ -30,7 +30,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "cocos2d-2.1rc0-x-2.1.2";
return "cocos2d-2.1rc0-x-2.1.3";
}
NS_CC_END

View File

@ -62,6 +62,11 @@ bool CCFileUtilsAndroid::init()
bool CCFileUtilsAndroid::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
bool bFound = false;
// Check whether file exists in apk.

View File

@ -53,6 +53,11 @@ bool CCFileUtilsBlackberry::isAbsolutePath(const std::string& strPath)
bool CCFileUtilsBlackberry::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
std::string strPath = strFilePath;
if (strPath[0] != '/')
{ // Not absolute path, add the default root path at the beginning.

View File

@ -161,23 +161,33 @@ std::string CCFileUtilsIOS::getWritablePath()
bool CCFileUtilsIOS::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
bool bRet = false;
if (strFilePath[0] != '/')
{
std::string path = strFilePath;
std::string path;
std::string file;
size_t pos = path.find_last_of("/");
size_t pos = strFilePath.find_last_of("/");
if (pos != std::string::npos)
{
file = path.substr(pos+1);
path = path.substr(0, pos+1);
NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:file.c_str()]
ofType:nil
inDirectory:[NSString stringWithUTF8String:path.c_str()]];
if (fullpath != nil) {
bRet = true;
}
file = strFilePath.substr(pos+1);
path = strFilePath.substr(0, pos+1);
}
else
{
file = strFilePath;
}
NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:file.c_str()]
ofType:nil
inDirectory:[NSString stringWithUTF8String:path.c_str()]];
if (fullpath != nil) {
bRet = true;
}
}
else

View File

@ -75,6 +75,11 @@ string CCFileUtilsLinux::getWritablePath()
bool CCFileUtilsLinux::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
std::string strPath = strFilePath;
if (!isAbsolutePath(strPath))
{ // Not absolute path, add the default root path at the beginning.

View File

@ -158,6 +158,11 @@ std::string CCFileUtilsMac::getWritablePath()
bool CCFileUtilsMac::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
bool bRet = false;
if (strFilePath[0] != '/')

View File

@ -30,6 +30,11 @@ string CCFileUtilsMarmalade::getWritablePath()
bool CCFileUtilsMarmalade::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
return s3eFileCheckExists(strFilePath.c_str()) == S3E_TRUE ? true : false;
}

View File

@ -48,6 +48,11 @@ std::string CCFileUtilsNaCl::getWritablePath()
bool CCFileUtilsNaCl::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
std::string strPath = strFilePath;
if (!isAbsolutePath(strPath))
{ // Not absolute path, add the default root path at the beginning.

View File

@ -66,6 +66,11 @@ bool CCFileUtilsWin32::init()
bool CCFileUtilsWin32::isFileExist(const std::string& strFilePath)
{
if (0 == strFilePath.length())
{
return false;
}
std::string strPath = strFilePath;
if (!isAbsolutePath(strPath))
{ // Not absolute path, add the default root path at the beginning.

View File

@ -133,7 +133,7 @@
<tool id="com.qnx.qcc.tool.compiler.1179668410" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compiler.shared.718070472" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.optlevel.1590845859" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compiler.security.1002115767" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1002115767" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.129076576" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -234,7 +234,7 @@
<option id="com.qnx.qcc.option.compiler.shared.1114058572" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.406582594" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.961992305" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.153635788" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.153635788" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1800808145" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -337,7 +337,7 @@
<option id="com.qnx.qcc.option.compiler.shared.1398782616" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.747278373" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.500128479" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.705064030" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.705064030" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.717586391" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -541,7 +541,7 @@
<option id="com.qnx.qcc.option.compiler.shared.2083466426" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.738577587" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.816625995" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.2065362383" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.2065362383" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.419624813" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -643,7 +643,7 @@
<option id="com.qnx.qcc.option.compiler.shared.586978887" name="Shared (-shared)" superClass="com.qnx.qcc.option.compiler.shared" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compile.debug.1492145683" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.1789362904" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.450368034" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.450368034" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.2095959994" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>

View File

@ -42,7 +42,6 @@ THE SOFTWARE.
#include <queue>
#include <list>
#include <pthread.h>
#include <semaphore.h>
using namespace std;
@ -64,26 +63,15 @@ typedef struct _ImageInfo
static pthread_t s_loadingThread;
static pthread_mutex_t s_SleepMutex;
static pthread_cond_t s_SleepCondition;
static pthread_mutex_t s_asyncStructQueueMutex;
static pthread_mutex_t s_ImageInfoMutex;
static sem_t* s_pSem = NULL;
static unsigned long s_nAsyncRefCount = 0;
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#define CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE 1
#else
#define CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE 0
#endif
#if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE
#define CC_ASYNC_TEXTURE_CACHE_SEMAPHORE "ccAsync"
#else
static sem_t s_sem;
#endif
static bool need_quit = false;
static std::queue<AsyncStruct*>* s_pAsyncStructQueue = NULL;
@ -123,24 +111,18 @@ static void* loadImage(void* data)
CCThread thread;
thread.createAutoreleasePool();
// wait for rendering thread to ask for loading if s_pAsyncStructQueue is empty
int semWaitRet = sem_wait(s_pSem);
if( semWaitRet < 0 )
{
CCLOG( "CCTextureCache async thread semaphore error: %s\n", strerror( errno ) );
break;
}
std::queue<AsyncStruct*> *pQueue = s_pAsyncStructQueue;
pthread_mutex_lock(&s_asyncStructQueueMutex);// get async struct from queue
if (pQueue->empty())
{
pthread_mutex_unlock(&s_asyncStructQueueMutex);
if (need_quit)
if (need_quit) {
break;
else
}
else {
pthread_cond_wait(&s_SleepCondition, &s_SleepMutex);
continue;
}
}
else
{
@ -182,17 +164,17 @@ static void* loadImage(void* data)
pthread_mutex_unlock(&s_ImageInfoMutex);
}
if( s_pSem != NULL )
if( s_pAsyncStructQueue != NULL )
{
#if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE
sem_unlink(CC_ASYNC_TEXTURE_CACHE_SEMAPHORE);
sem_close(s_pSem);
#else
sem_destroy(s_pSem);
#endif
s_pSem = NULL;
delete s_pAsyncStructQueue;
s_pAsyncStructQueue = NULL;
delete s_pImageQueue;
s_pImageQueue = NULL;
pthread_mutex_destroy(&s_asyncStructQueueMutex);
pthread_mutex_destroy(&s_ImageInfoMutex);
pthread_mutex_destroy(&s_SleepMutex);
pthread_cond_destroy(&s_SleepCondition);
}
return 0;
@ -223,11 +205,8 @@ CCTextureCache::~CCTextureCache()
{
CCLOGINFO("cocos2d: deallocing CCTextureCache.");
need_quit = true;
if (s_pSem != NULL)
{
sem_post(s_pSem);
}
pthread_cond_signal(&s_SleepCondition);
CC_SAFE_RELEASE(m_pTextures);
}
@ -277,30 +256,15 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
}
// lazy init
if (s_pSem == NULL)
if (s_pAsyncStructQueue == NULL)
{
#if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE
s_pSem = sem_open(CC_ASYNC_TEXTURE_CACHE_SEMAPHORE, O_CREAT, 0644, 0);
if( s_pSem == SEM_FAILED )
{
CCLOG( "CCTextureCache async thread semaphore init error: %s\n", strerror( errno ) );
s_pSem = NULL;
return;
}
#else
int semInitRet = sem_init(&s_sem, 0, 0);
if( semInitRet < 0 )
{
CCLOG( "CCTextureCache async thread semaphore init error: %s\n", strerror( errno ) );
return;
}
s_pSem = &s_sem;
#endif
s_pAsyncStructQueue = new queue<AsyncStruct*>();
s_pImageQueue = new queue<ImageInfo*>();
pthread_mutex_init(&s_asyncStructQueueMutex, NULL);
pthread_mutex_init(&s_ImageInfoMutex, NULL);
pthread_mutex_init(&s_SleepMutex, NULL);
pthread_cond_init(&s_SleepCondition, NULL);
pthread_create(&s_loadingThread, NULL, loadImage, NULL);
need_quit = false;
@ -329,7 +293,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
s_pAsyncStructQueue->push(data);
pthread_mutex_unlock(&s_asyncStructQueueMutex);
sem_post(s_pSem);
pthread_cond_signal(&s_SleepCondition);
}
void CCTextureCache::addImageAsyncCallBack(float dt)

View File

@ -1,85 +0,0 @@
#!/bin/sh
HELLOWORLD_ROOT=`pwd`/template/blackberry
# make directory qnx and copy all files and directories into it
copy_qnx_folder(){
if [ -d $PROJECT_DIR/proj.blackberry ]; then
echo "The '$PROJECT_NAME' project exists, can't override! Please input again!"
create_qnx_project
exit
fi
mkdir $PROJECT_DIR/proj.blackberry
echo $HELLOWORLD_ROOT
for file in `ls -a $HELLOWORLD_ROOT/proj.blackberry | grep -E '\.(project|cproject|xml|png|cpp)' `
do
file=$HELLOWORLD_ROOT/proj.blackberry/$file
if [ -f $file ];then
#echo $file
cp $file $PROJECT_DIR/proj.blackberry
fi
done
}
copy_cpp_h_from_helloworld(){
if [ -d $PROJECT_DIR/Classes ]; then
echo "Classes folder exists, skip copying Classes folder!"
else
mkdir $PROJECT_DIR/Classes
for file in `ls $HELLOWORLD_ROOT/Classes/* | grep -E '.(cpp|h|mk)' `
do
if [ -f $file ];then
#echo $file
cp $file $PROJECT_DIR/Classes
fi
done
fi
}
# copy resources
copy_resouces(){
if [ -d $PROJECT_DIR/Resources ]; then
echo "Resources folder exists, skip copying Resources folder!"
else
mkdir $PROJECT_DIR/Resources
for file in $HELLOWORLD_ROOT/Resources/*
do
#echo $file
cp $file $PROJECT_DIR/Resources
done
fi
}
# replace string
modify_file_content(){
# here should use # instead of /, why??
sed "s#$2#$3#g" $PROJECT_DIR/proj.blackberry/$1 > $PROJECT_DIR/proj.blackberry/tmp.txt
rm $PROJECT_DIR/proj.blackberry/$1
mv $PROJECT_DIR/proj.blackberry/tmp.txt $PROJECT_DIR/proj.blackberry/$1
}
create_qnx_project(){
echo "Please input your project name:"
read PROJECT_NAME
PROJECT_DIR=`pwd`/$PROJECT_NAME
# check if PROJECT_DIR is exist
if [ -d $PROJECT_DIR ]; then
echo ""
else
mkdir $PROJECT_DIR
fi
copy_qnx_folder
modify_file_content .project BBTemplateProject $PROJECT_NAME
modify_file_content .cproject BBTemplateProject $PROJECT_NAME
modify_file_content bar-descriptor.xml BBTemplateProject $PROJECT_NAME
modify_file_content .cproject ../../../.. ../../..
modify_file_content bar-descriptor.xml empty/../../../.. empty/../../..
copy_cpp_h_from_helloworld
copy_resouces
echo "Congratulations, the '$PROJECT_NAME' project have been created successfully, please use QNX IDE to import the project!"
}
create_qnx_project

View File

@ -1,81 +0,0 @@
set fso = Wscript.CreateObject("Scripting.FileSystemObject")
dim szPrompt, msgRet
szPrompt = "Prompt"
function ReplaceFileContent(fileName, oldStr, newStr)
set f = fso.opentextfile(fileName)
s = replace(f.readall, oldStr, newStr)
f.close
set r = fso.opentextfile(fileName, 2, true)
r.write s
end function
function CopyFolder(srcFolder, desFolder)
if (fso.FolderExists(desFolder)) then
'msgbox("none:"+srcFolder+":"+desFolder)
'If the desFolder exist, do nothing.
else
CopyFolder = fso.CopyFolder(srcFolder, desFolder)
end if
end function
function ConfigureProject()
dim szProjectName
szProjectName = Inputbox("Please Input Project Name:", szPrompt)
if szProjectName = "" then
Wscript.quit
end if
if (0 = strcomp(szProjectName, "HelloWorld", 1) or 0 = strcomp(szProjectName, "tests", 1)) then
msgRet = msgbox("Can not create a project named with "+szProjectName+", Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wscript.quit
end if
if (fso.FolderExists(szProjectName)) then
else
fso.CreateFolder(szProjectName)
end if
dim qnxFolder
qnxFolder = szProjectName + "\proj.blackberry"
if (fso.FolderExists(qnxFolder)) then
msgRet = msgbox("The '"+szProjectName+"' project exists, can't override! Please input again!", 1, szPrompt)
if (msgRet = 1) then
call ConfigureProject
end if
Wcript.quit
end if
dim szSrcClass, szSrcQnx, szSrcResource
dim szDesClass, szDesQnx, szDesResource
szSrcClass = "template\blackberry\Classes"
szSrcQnx = "template\blackberry\proj.blackberry"
szSrcResource = "template\blackberry\Resources"
szDesClass = szProjectName+"\Classes"
szDesQnx = szProjectName+"\proj.blackberry"
szDesResource = szProjectName+"\Resources"
call CopyFolder(szSrcClass, szDesClass)
call CopyFolder(szSrcQnx, szDesQnx)
call CopyFolder(szSrcResource, szDesResource)
call ReplaceFileContent(szProjectName+"\proj.blackberry\bar-descriptor.xml", "BBTemplateProject", szProjectName)
call ReplaceFileContent(szProjectName+"\proj.blackberry\bar-descriptor.xml", "../../../..", "../../..")
call ReplaceFileContent(szProjectName+"\proj.blackberry\.project", "BBTemplateProject", szProjectName)
call ReplaceFileContent(szProjectName+"\proj.blackberry\.cproject", "BBTemplateProject", szProjectName)
call ReplaceFileContent(szProjectName+"\proj.blackberry\.cproject", "../../../..", "../../..")
call msgbox("Congratulations, the '"+szProjectName+"' project have been created successfully, please use QNX IDE to import the project!", 0, szPrompt)
end function
call ConfigureProject
Wscript.quit

View File

@ -132,7 +132,7 @@ bool CCScrollView::init()
void CCScrollView::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, CCLayer::getTouchPriority(), false);
}
bool CCScrollView::isNodeVisible(CCNode* node)

View File

@ -28,7 +28,6 @@
#include <queue>
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include "curl/curl.h"
@ -38,21 +37,12 @@ NS_CC_EXT_BEGIN
static pthread_t s_networkThread;
static pthread_mutex_t s_requestQueueMutex;
static pthread_mutex_t s_responseQueueMutex;
static sem_t * s_pSem = NULL;
static pthread_mutex_t s_SleepMutex;
static pthread_cond_t s_SleepCondition;
static unsigned long s_asyncRequestCount = 0;
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#define CC_ASYNC_HTTPREQUEST_USE_NAMED_SEMAPHORE 1
#else
#define CC_ASYNC_HTTPREQUEST_USE_NAMED_SEMAPHORE 0
#endif
#if CC_ASYNC_HTTPREQUEST_USE_NAMED_SEMAPHORE
#define CC_ASYNC_HTTPREQUEST_SEMAPHORE "ccHttpAsync"
#else
static sem_t s_sem;
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
typedef int int32_t;
#endif
@ -96,13 +86,6 @@ static void* networkThread(void *data)
while (true)
{
// Wait for http request tasks from main thread
int semWaitRet = sem_wait(s_pSem);
if (semWaitRet < 0) {
CCLog("HttpRequest async thread semaphore error: %s", strerror(errno));
break;
}
if (need_quit)
{
break;
@ -122,6 +105,8 @@ static void* networkThread(void *data)
if (NULL == request)
{
// Wait for http request tasks from main thread
pthread_cond_wait(&s_SleepCondition, &s_SleepMutex);
continue;
}
@ -188,21 +173,18 @@ static void* networkThread(void *data)
pthread_mutex_unlock(&s_requestQueueMutex);
s_asyncRequestCount -= s_requestQueue->count();
if (s_pSem != NULL) {
#if CC_ASYNC_HTTPREQUEST_USE_NAMED_SEMAPHORE
sem_unlink(CC_ASYNC_HTTPREQUEST_SEMAPHORE);
sem_close(s_pSem);
#else
sem_destroy(s_pSem);
#endif
s_pSem = NULL;
if (s_requestQueue != NULL) {
pthread_mutex_destroy(&s_requestQueueMutex);
pthread_mutex_destroy(&s_responseQueueMutex);
pthread_mutex_destroy(&s_SleepMutex);
pthread_cond_destroy(&s_SleepCondition);
s_requestQueue->release();
s_requestQueue = NULL;
s_responseQueue->release();
s_responseQueue = NULL;
}
pthread_exit(NULL);
@ -416,8 +398,8 @@ CCHttpClient::~CCHttpClient()
{
need_quit = true;
if (s_pSem != NULL) {
sem_post(s_pSem);
if (s_requestQueue != NULL) {
pthread_cond_signal(&s_SleepCondition);
}
s_pHttpClient = NULL;
@ -426,25 +408,9 @@ CCHttpClient::~CCHttpClient()
//Lazy create semaphore & mutex & thread
bool CCHttpClient::lazyInitThreadSemphore()
{
if (s_pSem != NULL) {
if (s_requestQueue != NULL) {
return true;
} else {
#if CC_ASYNC_HTTPREQUEST_USE_NAMED_SEMAPHORE
s_pSem = sem_open(CC_ASYNC_HTTPREQUEST_SEMAPHORE, O_CREAT, 0644, 0);
if (s_pSem == SEM_FAILED) {
CCLog("Open HttpRequest Semaphore failed");
s_pSem = NULL;
return false;
}
#else
int semRet = sem_init(&s_sem, 0, 0);
if (semRet < 0) {
CCLog("Init HttpRequest Semaphore failed");
return false;
}
s_pSem = &s_sem;
#endif
s_requestQueue = new CCArray();
s_requestQueue->init();
@ -455,6 +421,9 @@ bool CCHttpClient::lazyInitThreadSemphore()
pthread_mutex_init(&s_requestQueueMutex, NULL);
pthread_mutex_init(&s_responseQueueMutex, NULL);
pthread_mutex_init(&s_SleepMutex, NULL);
pthread_cond_init(&s_SleepCondition, NULL);
pthread_create(&s_networkThread, NULL, networkThread, NULL);
pthread_detach(s_networkThread);
@ -486,7 +455,7 @@ void CCHttpClient::send(CCHttpRequest* request)
pthread_mutex_unlock(&s_requestQueueMutex);
// Notify thread start to work
sem_post(s_pSem);
pthread_cond_signal(&s_SleepCondition);
}
// Poll and notify main thread if responses exists in queue

View File

@ -52,6 +52,7 @@
<option id="com.qnx.qcc.option.compiler.security.1291922980" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1492222929" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="COCOS2D_DEBUG=1"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
</option>
<inputType id="com.qnx.qcc.inputType.compiler.417359789" superClass="com.qnx.qcc.inputType.compiler"/>
@ -84,6 +85,7 @@
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="GUI"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="network"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="physics_nodes"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="spine"/>
</sourceEntries>
</configuration>
</storageModule>
@ -125,7 +127,7 @@
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.803735203" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.803735203" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.361044144" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
@ -203,7 +205,7 @@
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.310444700" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.310444700" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.41889260" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
@ -279,7 +281,7 @@
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.1187262169" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1187262169" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.670664466" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
@ -428,7 +430,7 @@
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.1681239974" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1681239974" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1641753022" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
@ -503,7 +505,7 @@
<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
<listOptionValue builtIn="false" value="${QNX_TARGET}/usr/include/freetype2"/>
</option>
<option id="com.qnx.qcc.option.compiler.security.309955164" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.309955164" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.919408513" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>

View File

@ -99,6 +99,11 @@
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/physics_nodes</locationURI>
</link>
<link>
<name>spine</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/spine</locationURI>
</link>
</linkedResources>
<filteredResources>
<filter>

View File

@ -55,9 +55,14 @@ void AtlasRegion_dispose (AtlasRegion* self) {
/**/
typedef struct {
typedef struct _struct_Str {
const char* begin;
const char* end;
_struct_Str()
: begin(NULL)
, end(NULL) {
}
} Str;
static void trim (Str* str) {

View File

@ -58,7 +58,7 @@ Skeleton* Skeleton_create (SkeletonData* data) {
SlotData *slotData = data->slots[i];
/* Find bone for the slotData's boneData. */
Bone *bone;
Bone *bone = NULL;
for (ii = 0; ii < self->boneCount; ++ii) {
if (data->bones[ii] == slotData->boneData) {
bone = self->bones[ii];

View File

@ -25,6 +25,7 @@
#include <spine/Skin.h>
#include <spine/extension.h>
#include <stdio.h>
namespace cocos2d { namespace extension {
@ -74,7 +75,7 @@ void Skin_dispose (Skin* self) {
FREE(self->name);
FREE(self);
}
#include <stdio.h>
void Skin_addAttachment (Skin* self, int slotIndex, const char* name, Attachment* attachment) {
_Entry* newEntry = _Entry_create(slotIndex, name, attachment);
newEntry->next = SUB_CAST(_Internal, self)->entries;

View File

@ -59,8 +59,9 @@ char* _readFile (const char* path, int* length) {
fseek(file, 0, SEEK_SET);
char* data = MALLOC(char, *length);
fread(data, 1, *length, file);
int rtn = fread(data, 1, *length, file);
fclose(file);
if (rtn != *length) return 0;
return data;
}

View File

@ -86,7 +86,7 @@
<builder buildPath="${workspace_loc:/Box2D/Device-Release}" id="com.qnx.nto.108427481" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
<tool id="com.qnx.qcc.tool.compiler.1301033997" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compiler.optlevel.1454373594" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compiler.security.1250268639" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1250268639" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.1083818888" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -147,7 +147,7 @@
<tool id="com.qnx.qcc.tool.compiler.310470410" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.1846714418" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.261822601" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.923321398" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.923321398" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.685307316" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -209,7 +209,7 @@
<tool id="com.qnx.qcc.tool.compiler.695022321" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.270536106" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.1257902614" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1013746750" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1013746750" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.550265575" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -329,7 +329,7 @@
<tool id="com.qnx.qcc.tool.compiler.185132119" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.1204233844" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.731650613" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1585868560" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1585868560" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.910592970" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -390,7 +390,7 @@
<tool id="com.qnx.qcc.tool.compiler.1851607432" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.681756134" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.387331607" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.425554066" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.425554066" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.238549369" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>

View File

@ -74,7 +74,7 @@
<builder buildPath="${workspace_loc:/chipmunk/Device-Release}" id="com.qnx.nto.335369697" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
<tool id="com.qnx.qcc.tool.compiler.2108489999" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compiler.optlevel.1215729712" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.2" valueType="enumerated"/>
<option id="com.qnx.qcc.option.compiler.security.1316447034" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1316447034" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.713018398" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -129,7 +129,7 @@
<tool id="com.qnx.qcc.tool.compiler.2019795858" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.33006691" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.1478507026" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.231139245" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.231139245" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.382524008" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -185,7 +185,7 @@
<tool id="com.qnx.qcc.tool.compiler.420590946" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.2159009" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.70969128" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1484426115" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1484426115" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.145100704" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -293,7 +293,7 @@
<tool id="com.qnx.qcc.tool.compiler.2123060390" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.437266444" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.profile2.745436841" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.606175389" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.606175389" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.698647246" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>
@ -348,7 +348,7 @@
<tool id="com.qnx.qcc.tool.compiler.1166991280" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.440607623" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.coverage.1949688106" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1965004546" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.1965004546" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.defines.660061720" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
</option>

View File

@ -0,0 +1,314 @@
#include "jsb_pluginx_admob_auto.hpp"
#include "jsb_pluginx_spidermonkey_specifics.h"
#include "jsb_pluginx_basic_conversions.h"
using namespace pluginx;
#include "AdsAdmob.h"
template<class T>
static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
TypeTest<T> t;
T* cobj = new T();
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
assert(p);
JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto);
js_proxy_t *pp;
JS_NEW_PROXY(pp, cobj, _tmp);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp));
return JS_TRUE;
}
static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
return JS_FALSE;
}
JSClass *jsb_AdsAdmob_class;
JSObject *jsb_AdsAdmob_prototype;
JSBool js_pluginx_admob_AdsAdmob_showAds(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->showAds(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
if (argc == 2) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
int arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->showAds(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
if (argc == 3) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
int arg1;
cocos2d::plugin::ProtocolAds::AdsPos arg2;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->showAds(arg0, arg1, arg2);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_hideAds(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->hideAds(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_addTestDevice(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
const char* arg0;
std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str();
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->addTestDevice(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TAdsDeveloperInfo arg0;
ok &= jsval_to_TAdsDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getSDKVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_admob_AdsAdmob_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::AdsAdmob* cobj = (cocos2d::plugin::AdsAdmob *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
JSBool arg0;
ok &= JS_ValueToBoolean(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->setDebugMode(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
extern JSObject *jsb_ProtocolAds_prototype;
void js_pluginx_admob_AdsAdmob_finalize(JSFreeOp *fop, JSObject *obj) {
js_proxy_t* nproxy;
js_proxy_t* jsproxy;
JS_GET_NATIVE_PROXY(jsproxy, obj);
if (jsproxy) {
JS_GET_PROXY(nproxy, jsproxy->ptr);
// cocos2d::plugin::AdsAdmob *nobj = static_cast<cocos2d::plugin::AdsAdmob *>(nproxy->ptr);
// if (nobj)
// delete nobj;
JS_REMOVE_PROXY(nproxy, jsproxy);
}
}
void js_register_pluginx_admob_AdsAdmob(JSContext *cx, JSObject *global) {
jsb_AdsAdmob_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_AdsAdmob_class->name = "AdsAdmob";
jsb_AdsAdmob_class->addProperty = JS_PropertyStub;
jsb_AdsAdmob_class->delProperty = JS_PropertyStub;
jsb_AdsAdmob_class->getProperty = JS_PropertyStub;
jsb_AdsAdmob_class->setProperty = JS_StrictPropertyStub;
jsb_AdsAdmob_class->enumerate = JS_EnumerateStub;
jsb_AdsAdmob_class->resolve = JS_ResolveStub;
jsb_AdsAdmob_class->convert = JS_ConvertStub;
jsb_AdsAdmob_class->finalize = js_pluginx_admob_AdsAdmob_finalize;
jsb_AdsAdmob_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
JSPropertySpec *properties = NULL;
static JSFunctionSpec funcs[] = {
JS_FN("showAds", js_pluginx_admob_AdsAdmob_showAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("hideAds", js_pluginx_admob_AdsAdmob_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("addTestDevice", js_pluginx_admob_AdsAdmob_addTestDevice, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_admob_AdsAdmob_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_admob_AdsAdmob_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_admob_AdsAdmob_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_admob_AdsAdmob_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_admob_AdsAdmob_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_admob_AdsAdmob_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
jsb_AdsAdmob_prototype = JS_InitClass(
cx, global,
jsb_ProtocolAds_prototype,
jsb_AdsAdmob_class,
empty_constructor, 0,
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
JSBool found;
JS_SetPropertyAttributes(cx, global, "AdsAdmob", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::AdsAdmob> t;
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId;
p->jsclass = jsb_AdsAdmob_class;
p->proto = jsb_AdsAdmob_prototype;
p->parentProto = jsb_ProtocolAds_prototype;
HASH_ADD_INT(_js_global_type_ht, type, p);
}
}
void register_all_pluginx_admob(JSContext* cx, JSObject* obj) {
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, obj, "plugin", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "plugin", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_pluginx_admob_AdsAdmob(cx, obj);
}

View File

@ -0,0 +1,25 @@
#ifndef __pluginx_admob_h__
#define __pluginx_admob_h__
#include "jsapi.h"
#include "jsfriendapi.h"
extern JSClass *jsb_AdsAdmob_class;
extern JSObject *jsb_AdsAdmob_prototype;
JSBool js_pluginx_admob_AdsAdmob_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_admob_AdsAdmob_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_admob_AdsAdmob(JSContext *cx, JSObject *global);
void register_all_pluginx_admob(JSContext* cx, JSObject* obj);
JSBool js_pluginx_admob_AdsAdmob_showAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_hideAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_addTestDevice(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_admob_AdsAdmob_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
#endif

View File

@ -0,0 +1,67 @@
/**
* @module pluginx_admob
*/
var plugin = plugin || {};
/**
* @class AdsAdmob
*/
plugin.AdsAdmob = {
/**
* @method showAds
* @param {cocos2d::plugin::ProtocolAds::AdsType}
* @param {int}
* @param {cocos2d::plugin::ProtocolAds::AdsPos}
*/
showAds : function () {},
/**
* @method hideAds
* @param {cocos2d::plugin::ProtocolAds::AdsType}
*/
hideAds : function () {},
/**
* @method addTestDevice
* @param {const char*}
*/
addTestDevice : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method configDeveloperInfo
* @param {TAdsDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "const char*"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
};

View File

@ -28,6 +28,26 @@ static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
JSClass *jsb_IAPAlipay_class;
JSObject *jsb_IAPAlipay_prototype;
JSBool js_pluginx_alipay_IAPAlipay_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::IAPAlipay* cobj = (cocos2d::plugin::IAPAlipay *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TIAPDeveloperInfo arg0;
ok &= jsval_to_TIAPDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_alipay_IAPAlipay_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
@ -79,26 +99,6 @@ JSBool js_pluginx_alipay_IAPAlipay_init(JSContext *cx, uint32_t argc, jsval *vp)
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_alipay_IAPAlipay_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::IAPAlipay* cobj = (cocos2d::plugin::IAPAlipay *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TDeveloperInfo arg0;
ok &= jsval_to_TDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->initDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_alipay_IAPAlipay_payForProduct(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
@ -191,14 +191,14 @@ void js_register_pluginx_alipay_IAPAlipay(JSContext *cx, JSObject *global) {
JSPropertySpec *properties = NULL;
static JSFunctionSpec funcs[] = {
JS_FN("configDeveloperInfo", js_pluginx_alipay_IAPAlipay_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_alipay_IAPAlipay_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_alipay_IAPAlipay_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_alipay_IAPAlipay_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("initDeveloperInfo", js_pluginx_alipay_IAPAlipay_initDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("payForProduct", js_pluginx_alipay_IAPAlipay_payForProduct, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_alipay_IAPAlipay_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_alipay_IAPAlipay_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;

View File

@ -12,10 +12,10 @@ JSBool js_pluginx_alipay_IAPAlipay_constructor(JSContext *cx, uint32_t argc, jsv
void js_pluginx_alipay_IAPAlipay_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_alipay_IAPAlipay(JSContext *cx, JSObject *global);
void register_all_pluginx_alipay(JSContext* cx, JSObject* obj);
JSBool js_pluginx_alipay_IAPAlipay_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_payForProduct(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_alipay_IAPAlipay_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);

View File

@ -8,6 +8,12 @@ var plugin = plugin || {};
*/
plugin.IAPAlipay = {
/**
* @method configDeveloperInfo
* @param {TIAPDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
@ -26,12 +32,6 @@ getPluginVersion : function () {},
*/
init : function () {},
/**
* @method initDeveloperInfo
* @param {TDeveloperInfo}
*/
initDeveloperInfo : function () {},
/**
* @method payForProduct
* @param {TProductInfo}

View File

@ -523,7 +523,7 @@ void js_register_pluginx_flurry_AnalyticsFlurry(JSContext *cx, JSObject *global)
JS_FN("logTimedEventEnd", js_pluginx_flurry_AnalyticsFlurry_logTimedEventEnd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_flurry_AnalyticsFlurry_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_flurry_AnalyticsFlurry_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;

View File

@ -28,6 +28,26 @@ static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
JSClass *jsb_IAPNd91_class;
JSObject *jsb_IAPNd91_prototype;
JSBool js_pluginx_nd91_IAPNd91_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::IAPNd91* cobj = (cocos2d::plugin::IAPNd91 *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TIAPDeveloperInfo arg0;
ok &= jsval_to_TIAPDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_nd91_IAPNd91_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
@ -79,26 +99,6 @@ JSBool js_pluginx_nd91_IAPNd91_init(JSContext *cx, uint32_t argc, jsval *vp)
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_nd91_IAPNd91_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::IAPNd91* cobj = (cocos2d::plugin::IAPNd91 *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TDeveloperInfo arg0;
ok &= jsval_to_TDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->initDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_nd91_IAPNd91_payForProduct(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
@ -191,14 +191,14 @@ void js_register_pluginx_nd91_IAPNd91(JSContext *cx, JSObject *global) {
JSPropertySpec *properties = NULL;
static JSFunctionSpec funcs[] = {
JS_FN("configDeveloperInfo", js_pluginx_nd91_IAPNd91_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_nd91_IAPNd91_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_nd91_IAPNd91_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_nd91_IAPNd91_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("initDeveloperInfo", js_pluginx_nd91_IAPNd91_initDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("payForProduct", js_pluginx_nd91_IAPNd91_payForProduct, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_nd91_IAPNd91_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_nd91_IAPNd91_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;

View File

@ -12,10 +12,10 @@ JSBool js_pluginx_nd91_IAPNd91_constructor(JSContext *cx, uint32_t argc, jsval *
void js_pluginx_nd91_IAPNd91_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_nd91_IAPNd91(JSContext *cx, JSObject *global);
void register_all_pluginx_nd91(JSContext* cx, JSObject* obj);
JSBool js_pluginx_nd91_IAPNd91_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_payForProduct(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_nd91_IAPNd91_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);

View File

@ -8,6 +8,12 @@ var plugin = plugin || {};
*/
plugin.IAPNd91 = {
/**
* @method configDeveloperInfo
* @param {TIAPDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
@ -26,12 +32,6 @@ getPluginVersion : function () {},
*/
init : function () {},
/**
* @method initDeveloperInfo
* @param {TDeveloperInfo}
*/
initDeveloperInfo : function () {},
/**
* @method payForProduct
* @param {TProductInfo}

View File

@ -5,7 +5,8 @@ using namespace pluginx;
#include "PluginManager.h"
#include "ProtocolAnalytics.h"
#include "ProtocolIAP.h"
#include "ProtocolIAPOnLine.h"
#include "ProtocolAds.h"
#include "ProtocolSocial.h"
template<class T>
static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
@ -181,7 +182,7 @@ void js_register_pluginx_protocols_PluginProtocol(JSContext *cx, JSObject *globa
JS_FN("getPluginVersion", js_pluginx_protocols_PluginProtocol_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_PluginProtocol_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_PluginProtocol_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
@ -334,7 +335,7 @@ void js_register_pluginx_protocols_PluginManager(JSContext *cx, JSObject *global
static JSFunctionSpec funcs[] = {
JS_FN("unloadPlugin", js_pluginx_protocols_PluginManager_unloadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("loadPlugin", js_pluginx_protocols_PluginManager_loadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
@ -682,7 +683,7 @@ void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JSObject *gl
JS_FN("logTimedEventEnd", js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_protocols_ProtocolAnalytics_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_ProtocolAnalytics_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
@ -719,26 +720,6 @@ void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JSObject *gl
JSClass *jsb_ProtocolIAP_class;
JSObject *jsb_ProtocolIAP_prototype;
JSBool js_pluginx_protocols_ProtocolIAP_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TDeveloperInfo arg0;
ok &= jsval_to_TDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->initDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
@ -756,23 +737,6 @@ JSBool js_pluginx_protocols_ProtocolIAP_getPluginVersion(JSContext *cx, uint32_t
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
@ -793,6 +757,82 @@ JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t ar
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TIAPDeveloperInfo arg0;
ok &= jsval_to_TIAPDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 2) {
cocos2d::plugin::PayResultCode arg0;
const char* arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->onPayResult(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
@ -830,41 +870,6 @@ JSBool js_pluginx_protocols_ProtocolIAP_setDebugMode(JSContext *cx, uint32_t arg
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAP_payResult(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
if (argc == 2) {
cocos2d::plugin::EPayResult arg0;
const char* arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cocos2d::plugin::ProtocolIAP::payResult(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
return JS_FALSE;
}
extern JSObject *jsb_PluginProtocol_prototype;
@ -897,23 +902,23 @@ void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global)
jsb_ProtocolIAP_class->finalize = js_pluginx_protocols_ProtocolIAP_finalize;
jsb_ProtocolIAP_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
JSPropertySpec *properties = NULL;
static JSPropertySpec properties[] = {
{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
};
static JSFunctionSpec funcs[] = {
JS_FN("initDeveloperInfo", js_pluginx_protocols_ProtocolIAP_initDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_protocols_ProtocolIAP_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_ProtocolIAP_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("payForProduct", js_pluginx_protocols_ProtocolIAP_payForProduct, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolIAP_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_ProtocolIAP_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_protocols_ProtocolIAP_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("onPayResult", js_pluginx_protocols_ProtocolIAP_onPayResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_protocols_ProtocolIAP_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_ProtocolIAP_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_protocols_ProtocolIAP_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
JS_FN("payResult", js_pluginx_protocols_ProtocolIAP_payResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
jsb_ProtocolIAP_prototype = JS_InitClass(
cx, global,
@ -944,22 +949,44 @@ void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global)
}
JSClass *jsb_ProtocolIAPOnLine_class;
JSObject *jsb_ProtocolIAPOnLine_prototype;
JSClass *jsb_ProtocolAds_class;
JSObject *jsb_ProtocolAds_prototype;
JSBool js_pluginx_protocols_ProtocolIAPOnLine_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TDeveloperInfo arg0;
ok &= jsval_to_TDeveloperInfo(cx, argv[0], &arg0);
cocos2d::plugin::ProtocolAds::AdsType arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->initDeveloperInfo(arg0);
cobj->showAds(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
if (argc == 2) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
int arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->showAds(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
if (argc == 3) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
int arg1;
cocos2d::plugin::ProtocolAds::AdsPos arg2;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1);
ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->showAds(arg0, arg1, arg2);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
@ -967,11 +994,31 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_initDeveloperInfo(JSContext *cx, u
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
cocos2d::plugin::ProtocolAds::AdsType arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->hideAds(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolAds_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginVersion();
@ -984,11 +1031,50 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginVersion(JSContext *cx, ui
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_init(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 2) {
cocos2d::plugin::AdsResultCode arg0;
const char* arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->onAdsResult(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolAds_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
@ -1001,19 +1087,19 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_init(JSContext *cx, uint32_t argc,
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_payForProduct(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TProductInfo arg0;
ok &= jsval_to_TProductInfo(cx, argv[0], &arg0);
int arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->payForProduct(arg0);
cobj->spendPoints(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
@ -1021,11 +1107,51 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_payForProduct(JSContext *cx, uint3
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TAdsDeveloperInfo arg0;
ok &= jsval_to_TAdsDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
int arg0;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->onPlayerGetPoints(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolAds_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getSDKVersion();
@ -1038,13 +1164,13 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_getSDKVersion(JSContext *cx, uint3
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolAds_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
JSBool arg0;
@ -1058,11 +1184,96 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_setDebugMode(JSContext *cx, uint32
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
extern JSObject *jsb_PluginProtocol_prototype;
void js_pluginx_protocols_ProtocolAds_finalize(JSFreeOp *fop, JSObject *obj) {
js_proxy_t* nproxy;
js_proxy_t* jsproxy;
JS_GET_NATIVE_PROXY(jsproxy, obj);
if (jsproxy) {
JS_GET_PROXY(nproxy, jsproxy->ptr);
// cocos2d::plugin::ProtocolAds *nobj = static_cast<cocos2d::plugin::ProtocolAds *>(nproxy->ptr);
// if (nobj)
// delete nobj;
JS_REMOVE_PROXY(nproxy, jsproxy);
}
}
void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global) {
jsb_ProtocolAds_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_ProtocolAds_class->name = "ProtocolAds";
jsb_ProtocolAds_class->addProperty = JS_PropertyStub;
jsb_ProtocolAds_class->delProperty = JS_PropertyStub;
jsb_ProtocolAds_class->getProperty = JS_PropertyStub;
jsb_ProtocolAds_class->setProperty = JS_StrictPropertyStub;
jsb_ProtocolAds_class->enumerate = JS_EnumerateStub;
jsb_ProtocolAds_class->resolve = JS_ResolveStub;
jsb_ProtocolAds_class->convert = JS_ConvertStub;
jsb_ProtocolAds_class->finalize = js_pluginx_protocols_ProtocolAds_finalize;
jsb_ProtocolAds_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
static JSPropertySpec properties[] = {
{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
};
static JSFunctionSpec funcs[] = {
JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("hideAds", js_pluginx_protocols_ProtocolAds_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_protocols_ProtocolAds_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_protocols_ProtocolAds_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("onAdsResult", js_pluginx_protocols_ProtocolAds_onAdsResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_ProtocolAds_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("spendPoints", js_pluginx_protocols_ProtocolAds_spendPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolAds_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("onPlayerGetPoints", js_pluginx_protocols_ProtocolAds_onPlayerGetPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_protocols_ProtocolAds_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_ProtocolAds_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
jsb_ProtocolAds_prototype = JS_InitClass(
cx, global,
jsb_PluginProtocol_prototype,
jsb_ProtocolAds_class,
empty_constructor, 0,
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
JSBool found;
JS_SetPropertyAttributes(cx, global, "ProtocolAds", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::ProtocolAds> t;
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId;
p->jsclass = jsb_ProtocolAds_class;
p->proto = jsb_ProtocolAds_prototype;
p->parentProto = jsb_PluginProtocol_prototype;
HASH_ADD_INT(_js_global_type_ht, type, p);
}
}
JSClass *jsb_ProtocolSocial_class;
JSObject *jsb_ProtocolSocial_prototype;
JSBool js_pluginx_protocols_ProtocolSocial_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAPOnLine* cobj = (cocos2d::plugin::ProtocolIAPOnLine *)(proxy ? proxy->ptr : NULL);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
@ -1075,36 +1286,177 @@ JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginName(JSContext *cx, uint3
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolIAPOnLine_payFailedLocally(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_protocols_ProtocolSocial_onShareResult(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 2) {
cocos2d::plugin::EPayResult arg0;
cocos2d::plugin::ShareResultCode arg0;
const char* arg1;
ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0);
std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str();
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cocos2d::plugin::ProtocolIAPOnLine::payFailedLocally(arg0, arg1);
cobj->onShareResult(arg0, arg1);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments");
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_share(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TShareInfo arg0;
ok &= jsval_to_TShareInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->share(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TSocialDeveloperInfo arg0;
ok &= jsval_to_TSocialDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getSDKVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
JSBool arg0;
ok &= JS_ValueToBoolean(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->setDebugMode(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_protocols_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
cocos2d::plugin::ShareResultListener* arg0;
do {
js_proxy_t *proxy;
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]);
JS_GET_NATIVE_PROXY(proxy, tmpObj);
arg0 = (cocos2d::plugin::ShareResultListener*)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object");
} while (0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->setResultListener(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
extern JSObject *jsb_PluginProtocol_prototype;
void js_pluginx_protocols_ProtocolIAPOnLine_finalize(JSFreeOp *fop, JSObject *obj) {
void js_pluginx_protocols_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj) {
js_proxy_t* nproxy;
js_proxy_t* jsproxy;
JS_GET_NATIVE_PROXY(jsproxy, obj);
if (jsproxy) {
JS_GET_PROXY(nproxy, jsproxy->ptr);
// cocos2d::plugin::ProtocolIAPOnLine *nobj = static_cast<cocos2d::plugin::ProtocolIAPOnLine *>(nproxy->ptr);
// cocos2d::plugin::ProtocolSocial *nobj = static_cast<cocos2d::plugin::ProtocolSocial *>(nproxy->ptr);
// if (nobj)
// delete nobj;
@ -1112,41 +1464,42 @@ void js_pluginx_protocols_ProtocolIAPOnLine_finalize(JSFreeOp *fop, JSObject *ob
}
}
void js_register_pluginx_protocols_ProtocolIAPOnLine(JSContext *cx, JSObject *global) {
jsb_ProtocolIAPOnLine_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_ProtocolIAPOnLine_class->name = "ProtocolIAPOnLine";
jsb_ProtocolIAPOnLine_class->addProperty = JS_PropertyStub;
jsb_ProtocolIAPOnLine_class->delProperty = JS_PropertyStub;
jsb_ProtocolIAPOnLine_class->getProperty = JS_PropertyStub;
jsb_ProtocolIAPOnLine_class->setProperty = JS_StrictPropertyStub;
jsb_ProtocolIAPOnLine_class->enumerate = JS_EnumerateStub;
jsb_ProtocolIAPOnLine_class->resolve = JS_ResolveStub;
jsb_ProtocolIAPOnLine_class->convert = JS_ConvertStub;
jsb_ProtocolIAPOnLine_class->finalize = js_pluginx_protocols_ProtocolIAPOnLine_finalize;
jsb_ProtocolIAPOnLine_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global) {
jsb_ProtocolSocial_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_ProtocolSocial_class->name = "ProtocolSocial";
jsb_ProtocolSocial_class->addProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->delProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->getProperty = JS_PropertyStub;
jsb_ProtocolSocial_class->setProperty = JS_StrictPropertyStub;
jsb_ProtocolSocial_class->enumerate = JS_EnumerateStub;
jsb_ProtocolSocial_class->resolve = JS_ResolveStub;
jsb_ProtocolSocial_class->convert = JS_ConvertStub;
jsb_ProtocolSocial_class->finalize = js_pluginx_protocols_ProtocolSocial_finalize;
jsb_ProtocolSocial_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
JSPropertySpec *properties = NULL;
static JSPropertySpec properties[] = {
{0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER}
};
static JSFunctionSpec funcs[] = {
JS_FN("initDeveloperInfo", js_pluginx_protocols_ProtocolIAPOnLine_initDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_protocols_ProtocolIAPOnLine_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_ProtocolIAPOnLine_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("payForProduct", js_pluginx_protocols_ProtocolIAPOnLine_payForProduct, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_protocols_ProtocolIAPOnLine_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_ProtocolIAPOnLine_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginName", js_pluginx_protocols_ProtocolIAPOnLine_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FN("getPluginName", js_pluginx_protocols_ProtocolSocial_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("onShareResult", js_pluginx_protocols_ProtocolSocial_onShareResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_protocols_ProtocolSocial_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("share", js_pluginx_protocols_ProtocolSocial_share, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_protocols_ProtocolSocial_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolSocial_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_protocols_ProtocolSocial_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_protocols_ProtocolSocial_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setResultListener", js_pluginx_protocols_ProtocolSocial_setResultListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
static JSFunctionSpec st_funcs[] = {
JS_FN("payFailedLocally", js_pluginx_protocols_ProtocolIAPOnLine_payFailedLocally, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
jsb_ProtocolIAPOnLine_prototype = JS_InitClass(
jsb_ProtocolSocial_prototype = JS_InitClass(
cx, global,
jsb_PluginProtocol_prototype,
jsb_ProtocolIAPOnLine_class,
jsb_ProtocolSocial_class,
empty_constructor, 0,
properties,
funcs,
@ -1154,18 +1507,18 @@ void js_register_pluginx_protocols_ProtocolIAPOnLine(JSContext *cx, JSObject *gl
st_funcs);
// make the class enumerable in the registered namespace
JSBool found;
JS_SetPropertyAttributes(cx, global, "ProtocolIAPOnLine", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
JS_SetPropertyAttributes(cx, global, "ProtocolSocial", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::ProtocolIAPOnLine> t;
TypeTest<cocos2d::plugin::ProtocolSocial> t;
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId;
p->jsclass = jsb_ProtocolIAPOnLine_class;
p->proto = jsb_ProtocolIAPOnLine_prototype;
p->jsclass = jsb_ProtocolSocial_class;
p->proto = jsb_ProtocolSocial_prototype;
p->parentProto = jsb_PluginProtocol_prototype;
HASH_ADD_INT(_js_global_type_ht, type, p);
}
@ -1187,8 +1540,9 @@ void register_all_pluginx_protocols(JSContext* cx, JSObject* obj) {
js_register_pluginx_protocols_PluginProtocol(cx, obj);
js_register_pluginx_protocols_ProtocolIAP(cx, obj);
js_register_pluginx_protocols_PluginManager(cx, obj);
js_register_pluginx_protocols_ProtocolIAPOnLine(cx, obj);
js_register_pluginx_protocols_ProtocolSocial(cx, obj);
js_register_pluginx_protocols_ProtocolAnalytics(cx, obj);
js_register_pluginx_protocols_ProtocolAds(cx, obj);
js_register_pluginx_protocols_PluginManager(cx, obj);
}

View File

@ -59,29 +59,49 @@ JSBool js_pluginx_protocols_ProtocolIAP_constructor(JSContext *cx, uint32_t argc
void js_pluginx_protocols_ProtocolIAP_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolIAP_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAP_payResult(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolIAPOnLine_class;
extern JSObject *jsb_ProtocolIAPOnLine_prototype;
extern JSClass *jsb_ProtocolAds_class;
extern JSObject *jsb_ProtocolAds_prototype;
JSBool js_pluginx_protocols_ProtocolIAPOnLine_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolIAPOnLine_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolIAPOnLine(JSContext *cx, JSObject *global);
JSBool js_pluginx_protocols_ProtocolAds_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolAds_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_initDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_payForProduct(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolIAPOnLine_payFailedLocally(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolAds_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
extern JSClass *jsb_ProtocolSocial_class;
extern JSObject *jsb_ProtocolSocial_prototype;
JSBool js_pluginx_protocols_ProtocolSocial_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_protocols_ProtocolSocial_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global);
void register_all_pluginx_protocols(JSContext* cx, JSObject* obj);
JSBool js_pluginx_protocols_ProtocolSocial_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_onShareResult(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_share(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_protocols_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
#endif

View File

@ -168,18 +168,24 @@ setDebugMode : function () {},
*/
plugin.ProtocolIAP = {
/**
* @method initDeveloperInfo
* @param {TDeveloperInfo}
*/
initDeveloperInfo : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method payForProduct
* @param {TProductInfo}
*/
payForProduct : function () {},
/**
* @method configDeveloperInfo
* @param {TIAPDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
@ -187,10 +193,149 @@ getPluginVersion : function () {},
init : function () {},
/**
* @method payForProduct
* @param {TProductInfo}
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
payForProduct : function () {},
getPluginName : function () {},
/**
* @method onPayResult
* @param {cocos2d::plugin::PayResultCode}
* @param {const char*}
*/
onPayResult : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "const char*"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
};
/**
* @class ProtocolAds
*/
plugin.ProtocolAds = {
/**
* @method showAds
* @param {cocos2d::plugin::ProtocolAds::AdsType}
* @param {int}
* @param {cocos2d::plugin::ProtocolAds::AdsPos}
*/
showAds : function () {},
/**
* @method hideAds
* @param {cocos2d::plugin::ProtocolAds::AdsType}
*/
hideAds : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method onAdsResult
* @param {cocos2d::plugin::AdsResultCode}
* @param {const char*}
*/
onAdsResult : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method spendPoints
* @param {int}
*/
spendPoints : function () {},
/**
* @method configDeveloperInfo
* @param {TAdsDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method onPlayerGetPoints
* @param {int}
*/
onPlayerGetPoints : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "const char*"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
};
/**
* @class ProtocolSocial
*/
plugin.ProtocolSocial = {
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method onShareResult
* @param {cocos2d::plugin::ShareResultCode}
* @param {const char*}
*/
onShareResult : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method share
* @param {TShareInfo}
*/
share : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method configDeveloperInfo
* @param {TSocialDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getSDKVersion
@ -205,72 +350,9 @@ getSDKVersion : function () {},
setDebugMode : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
* @method setResultListener
* @param {cocos2d::plugin::ShareResultListener*}
*/
getPluginName : function () {},
/**
* @method payResult
* @param {cocos2d::plugin::EPayResult}
* @param {const char*}
*/
payResult : function () {},
};
/**
* @class ProtocolIAPOnLine
*/
plugin.ProtocolIAPOnLine = {
/**
* @method initDeveloperInfo
* @param {TDeveloperInfo}
*/
initDeveloperInfo : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method payForProduct
* @param {TProductInfo}
*/
payForProduct : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "const char*"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method payFailedLocally
* @param {cocos2d::plugin::EPayResult}
* @param {const char*}
*/
payFailedLocally : function () {},
setResultListener : function () {},
};

View File

@ -0,0 +1,250 @@
#include "jsb_pluginx_twitter_auto.hpp"
#include "jsb_pluginx_spidermonkey_specifics.h"
#include "jsb_pluginx_basic_conversions.h"
using namespace pluginx;
#include "SocialTwitter.h"
template<class T>
static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
TypeTest<T> t;
T* cobj = new T();
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
assert(p);
JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto);
js_proxy_t *pp;
JS_NEW_PROXY(pp, cobj, _tmp);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp));
return JS_TRUE;
}
static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) {
return JS_FALSE;
}
JSClass *jsb_SocialTwitter_class;
JSObject *jsb_SocialTwitter_prototype;
JSBool js_pluginx_twitter_SocialTwitter_getPluginName(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginName();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getPluginVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_share(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TShareInfo arg0;
ok &= jsval_to_TShareInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->share(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_init(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
bool ret = cobj->init();
jsval jsret;
jsret = BOOLEAN_TO_JSVAL(ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
TSocialDeveloperInfo arg0;
ok &= jsval_to_TSocialDeveloperInfo(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->configDeveloperInfo(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 0) {
const char* ret = cobj->getSDKVersion();
jsval jsret;
jsret = c_string_to_jsval(cx, ret);
JS_SET_RVAL(cx, vp, jsret);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0);
return JS_FALSE;
}
JSBool js_pluginx_twitter_SocialTwitter_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSBool ok = JS_TRUE;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::SocialTwitter* cobj = (cocos2d::plugin::SocialTwitter *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 1) {
JSBool arg0;
ok &= JS_ValueToBoolean(cx, argv[0], &arg0);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
cobj->setDebugMode(arg0);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
extern JSObject *jsb_ProtocolSocial_prototype;
void js_pluginx_twitter_SocialTwitter_finalize(JSFreeOp *fop, JSObject *obj) {
js_proxy_t* nproxy;
js_proxy_t* jsproxy;
JS_GET_NATIVE_PROXY(jsproxy, obj);
if (jsproxy) {
JS_GET_PROXY(nproxy, jsproxy->ptr);
// cocos2d::plugin::SocialTwitter *nobj = static_cast<cocos2d::plugin::SocialTwitter *>(nproxy->ptr);
// if (nobj)
// delete nobj;
JS_REMOVE_PROXY(nproxy, jsproxy);
}
}
void js_register_pluginx_twitter_SocialTwitter(JSContext *cx, JSObject *global) {
jsb_SocialTwitter_class = (JSClass *)calloc(1, sizeof(JSClass));
jsb_SocialTwitter_class->name = "SocialTwitter";
jsb_SocialTwitter_class->addProperty = JS_PropertyStub;
jsb_SocialTwitter_class->delProperty = JS_PropertyStub;
jsb_SocialTwitter_class->getProperty = JS_PropertyStub;
jsb_SocialTwitter_class->setProperty = JS_StrictPropertyStub;
jsb_SocialTwitter_class->enumerate = JS_EnumerateStub;
jsb_SocialTwitter_class->resolve = JS_ResolveStub;
jsb_SocialTwitter_class->convert = JS_ConvertStub;
jsb_SocialTwitter_class->finalize = js_pluginx_twitter_SocialTwitter_finalize;
jsb_SocialTwitter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2);
JSPropertySpec *properties = NULL;
static JSFunctionSpec funcs[] = {
JS_FN("getPluginName", js_pluginx_twitter_SocialTwitter_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getPluginVersion", js_pluginx_twitter_SocialTwitter_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("share", js_pluginx_twitter_SocialTwitter_share, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_pluginx_twitter_SocialTwitter_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("configDeveloperInfo", js_pluginx_twitter_SocialTwitter_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getSDKVersion", js_pluginx_twitter_SocialTwitter_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_twitter_SocialTwitter_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;
jsb_SocialTwitter_prototype = JS_InitClass(
cx, global,
jsb_ProtocolSocial_prototype,
jsb_SocialTwitter_class,
empty_constructor, 0,
properties,
funcs,
NULL, // no static properties
st_funcs);
// make the class enumerable in the registered namespace
JSBool found;
JS_SetPropertyAttributes(cx, global, "SocialTwitter", JSPROP_ENUMERATE | JSPROP_READONLY, &found);
// add the proto and JSClass to the type->js info hash table
TypeTest<cocos2d::plugin::SocialTwitter> t;
js_type_class_t *p;
uint32_t typeId = t.s_id();
HASH_FIND_INT(_js_global_type_ht, &typeId, p);
if (!p) {
p = (js_type_class_t *)malloc(sizeof(js_type_class_t));
p->type = typeId;
p->jsclass = jsb_SocialTwitter_class;
p->proto = jsb_SocialTwitter_prototype;
p->parentProto = jsb_ProtocolSocial_prototype;
HASH_ADD_INT(_js_global_type_ht, type, p);
}
}
void register_all_pluginx_twitter(JSContext* cx, JSObject* obj) {
// first, try to get the ns
jsval nsval;
JSObject *ns;
JS_GetProperty(cx, obj, "plugin", &nsval);
if (nsval == JSVAL_VOID) {
ns = JS_NewObject(cx, NULL, NULL, NULL);
nsval = OBJECT_TO_JSVAL(ns);
JS_SetProperty(cx, obj, "plugin", &nsval);
} else {
JS_ValueToObject(cx, nsval, &ns);
}
obj = ns;
js_register_pluginx_twitter_SocialTwitter(cx, obj);
}

View File

@ -0,0 +1,23 @@
#ifndef __pluginx_twitter_h__
#define __pluginx_twitter_h__
#include "jsapi.h"
#include "jsfriendapi.h"
extern JSClass *jsb_SocialTwitter_class;
extern JSObject *jsb_SocialTwitter_prototype;
JSBool js_pluginx_twitter_SocialTwitter_constructor(JSContext *cx, uint32_t argc, jsval *vp);
void js_pluginx_twitter_SocialTwitter_finalize(JSContext *cx, JSObject *obj);
void js_register_pluginx_twitter_SocialTwitter(JSContext *cx, JSObject *global);
void register_all_pluginx_twitter(JSContext* cx, JSObject* obj);
JSBool js_pluginx_twitter_SocialTwitter_getPluginName(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_share(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_init(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_twitter_SocialTwitter_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp);
#endif

View File

@ -0,0 +1,53 @@
/**
* @module pluginx_twitter
*/
var plugin = plugin || {};
/**
* @class SocialTwitter
*/
plugin.SocialTwitter = {
/**
* @method getPluginName
* @return A value converted from C/C++ "const char*"
*/
getPluginName : function () {},
/**
* @method getPluginVersion
* @return A value converted from C/C++ "const char*"
*/
getPluginVersion : function () {},
/**
* @method share
* @param {TShareInfo}
*/
share : function () {},
/**
* @method init
* @return A value converted from C/C++ "bool"
*/
init : function () {},
/**
* @method configDeveloperInfo
* @param {TSocialDeveloperInfo}
*/
configDeveloperInfo : function () {},
/**
* @method getSDKVersion
* @return A value converted from C/C++ "const char*"
*/
getSDKVersion : function () {},
/**
* @method setDebugMode
* @param {bool}
*/
setDebugMode : function () {},
};

View File

@ -621,7 +621,7 @@ void js_register_pluginx_umeng_AnalyticsUmeng(JSContext *cx, JSObject *global) {
JS_FN("logTimedEventEnd", js_pluginx_umeng_AnalyticsUmeng_logTimedEventEnd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("logEventWithLabel", js_pluginx_umeng_AnalyticsUmeng_logEventWithLabel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugMode", js_pluginx_umeng_AnalyticsUmeng_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END
JS_FS_END
};
JSFunctionSpec *st_funcs = NULL;

View File

@ -1,2 +1 @@
require('jsb_cocos2d_other.js');
require('jsb_pluginx_analytics.js');

View File

@ -196,7 +196,22 @@ JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret)
return JS_TRUE;
}
JSBool jsval_to_TDeveloperInfo(JSContext *cx, jsval v, TDeveloperInfo* ret)
JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret)
{
return jsval_to_TProductInfo(cx, v, ret);
}

View File

@ -6,6 +6,8 @@
#include "ProtocolIAP.h"
#include "ProtocolAnalytics.h"
#include "ProtocolAds.h"
#include "ProtocolSocial.h"
using namespace cocos2d::plugin;
@ -19,7 +21,10 @@ JSBool jsval_to_long(JSContext *cx, jsval v, long* ret);
JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret);
JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret);
JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret);
JSBool jsval_to_TDeveloperInfo(JSContext *cx, jsval v, TDeveloperInfo* ret);
JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret);
JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret);
JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret);
JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret);
JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map<std::string, std::string>* ret);
JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret);

View File

@ -9,6 +9,10 @@ static jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string)
return JSVAL_VOID;
}
extern JSObject *jsb_ProtocolIAP_prototype;
extern JSObject *jsb_ProtocolAds_prototype;
extern JSObject *jsb_ProtocolSocial_prototype;
void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
{
// first, try to get the ns
@ -23,12 +27,7 @@ void register_pluginx_js_extensions(JSContext* cx, JSObject* global)
JS_ValueToObject(cx, nsval, &ns);
}
JSObject *tmpObj;
tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return plugin.ProtocolIAP; })()"));
JS_DefineFunction(cx, tmpObj, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return plugin.ProtocolIAPOnLine; })()"));
JS_DefineFunction(cx, tmpObj, "setLocalResultListener", js_pluginx_ProtocolIAPOnLine_setLocalResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_ProtocolSocial_prototype, "setResultListener", js_pluginx_ProtocolSocial_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
}

View File

@ -1,7 +1,7 @@
#include "jsb_pluginx_manual_iap.h"
#include "jsb_pluginx_basic_conversions.h"
#include "jsb_pluginx_spidermonkey_specifics.h"
#include "ProtocolIAPOnLine.h"
#include "ProtocolAds.h"
using namespace pluginx;
@ -10,7 +10,7 @@ static JSContext* s_cx = NULL;
class Pluginx_PurchaseResult : public cocos2d::plugin::PayResultListener
{
public:
virtual void payResult(cocos2d::plugin::EPayResult ret, const char* msg, cocos2d::plugin::TProductInfo info)
virtual void onPayResult(cocos2d::plugin::PayResultCode ret, const char* msg, cocos2d::plugin::TProductInfo info)
{
char goodInfo[1024] = { 0 };
sprintf(goodInfo, "商品名称:%s\n商品价格:%s\n商品描述:%s",
@ -32,15 +32,15 @@ public:
JSObject* obj = m_pJSDelegate;
if (JS_HasProperty(cx, obj, "payResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "payResult", &temp_retval)) {
if (JS_HasProperty(cx, obj, "onPayResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onPayResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "payResult",
JS_CallFunctionName(cx, obj, "onPayResult",
3, dataVal, &retval);
}
}
@ -58,6 +58,9 @@ JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, js
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
@ -65,7 +68,7 @@ JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, js
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_PurchaseResult* nativeDelegate = new Pluginx_PurchaseResult();
nativeDelegate->setJSDelegate(jsDelegate);
cocos2d::plugin::ProtocolIAP::setResultListener(nativeDelegate);
cobj->setResultListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
@ -75,10 +78,105 @@ JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, js
return JS_FALSE;
}
class Pluginx_PurchaseLocalResult : public cocos2d::plugin::LocalResultListener
class Pluginx_AdsListener : public cocos2d::plugin::AdsListener
{
public:
virtual void payFailedLocally(cocos2d::plugin::EPayResult ret, const char* msg)
virtual void onAdsResult(AdsResultCode code, const char* msg)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
jsval dataVal[2];
dataVal[0] = INT_TO_JSVAL(code);
std::string strMsgInfo = msg;
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = m_pJSDelegate;
JSBool bRet = JS_HasProperty(cx, obj, "onAdsResult", &hasAction);
if (bRet && hasAction) {
if(!JS_GetProperty(cx, obj, "onAdsResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onAdsResult",
2, dataVal, &retval);
}
}
virtual void onPlayerGetPoints(ProtocolAds* pAdsPlugin, int points)
{
JSContext* cx = s_cx;
JSBool hasAction;
jsval retval;
jsval temp_retval;
js_proxy_t * p;
JS_GET_PROXY(p, pAdsPlugin);
if (! p) return;
jsval dataVal[2];
jsval arg = OBJECT_TO_JSVAL(p->obj);
dataVal[0] = arg;
dataVal[1] = INT_TO_JSVAL(points);
JSObject* obj = m_pJSDelegate;
JSBool bRet = JS_HasProperty(cx, obj, "onPlayerGetPoints", &hasAction);
if (bRet && hasAction) {
if(!JS_GetProperty(cx, obj, "onPlayerGetPoints", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "onPlayerGetPoints",
2, NULL, &retval);
}
}
void setJSDelegate(JSObject* pJSDelegate)
{
m_pJSDelegate = pJSDelegate;
}
private:
JSObject* m_pJSDelegate;
};
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_AdsListener* nativeDelegate = new Pluginx_AdsListener();
nativeDelegate->setJSDelegate(jsDelegate);
cobj->setAdsListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1);
return JS_FALSE;
}
class Pluginx_ShareResult : public cocos2d::plugin::ShareResultListener
{
public:
virtual void onShareResult(cocos2d::plugin::ShareResultCode ret, const char* msg)
{
JSContext* cx = s_cx;
@ -91,16 +189,16 @@ public:
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
JSObject* obj = m_pJSDelegate;
JSBool bRet = JS_HasProperty(cx, obj, "payFailedLocally", &hasAction);
if (bRet && hasAction) {
if(!JS_GetProperty(cx, obj, "payFailedLocally", &temp_retval)) {
if (JS_HasProperty(cx, obj, "onShareResult", &hasAction) && hasAction) {
if(!JS_GetProperty(cx, obj, "onShareResult", &temp_retval)) {
return;
}
if(temp_retval == JSVAL_VOID) {
return;
}
JSAutoCompartment ac(cx, obj);
JS_CallFunctionName(cx, obj, "payFailedLocally",
JS_CallFunctionName(cx, obj, "onShareResult",
2, dataVal, &retval);
}
}
@ -114,17 +212,21 @@ private:
JSObject* m_pJSDelegate;
};
JSBool js_pluginx_ProtocolIAPOnLine_setLocalResultListener(JSContext *cx, uint32_t argc, jsval *vp)
JSBool js_pluginx_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
{
s_cx = cx;
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL);
JSBool ok = JS_TRUE;
if (argc == 1) {
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
Pluginx_PurchaseLocalResult* nativeDelegate = new Pluginx_PurchaseLocalResult();
Pluginx_ShareResult* nativeDelegate = new Pluginx_ShareResult();
nativeDelegate->setJSDelegate(jsDelegate);
cocos2d::plugin::ProtocolIAPOnLine::setLocalResultListener(nativeDelegate);
cobj->setResultListener(nativeDelegate);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;

View File

@ -5,6 +5,7 @@
#include "jsfriendapi.h"
JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolIAPOnLine_setLocalResultListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp);
JSBool js_pluginx_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp);
#endif /* __JS_MANUAL_IAP_H__ */

View File

@ -1,3 +1,26 @@
/****************************************************************************
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__
@ -13,11 +36,11 @@ class AdsAdmob : public ProtocolAds
public:
typedef enum {
eSizeBanner = 0,
eSizeIABMRect,
eSizeIABBanner,
eSizeIABLeaderboard,
} ESizeAdmobBanner;
kSizeBanner = 0,
kSizeIABMRect,
kSizeIABBanner,
kSizeIABLeaderboard,
} AdmobBannerSize;
/**
@brief plugin initialization
@ -25,25 +48,30 @@ public:
virtual bool init();
/**
@brief initialize the application info
@param appInfo This parameter is the info of application, must contains:
@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 initAppInfo(TAppInfo appInfo);
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 show banner ads at specified position
@param pos The position where the banner view be shown
@param sizeEnum The size of the banner view. Use the value in ESizeAdmobBanner
@brief Hide the adview
@param type The adview type need to hide.
*/
virtual void showBannerAd(EBannerPos pos, int sizeEnum);
/**
@brief hide the banner ads view
*/
virtual void hideBannerAd();
virtual void hideAds(AdsType type);
/**
@brief Set whether needs to output logs to console.

View File

@ -23,11 +23,11 @@ cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common
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/IAPAlipay.h
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 = IAPAlipay
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
@ -53,7 +53,7 @@ base_classes_to_skip =
# classes that create no constructor
# CCSet is special and we will use a hand-written constructor
abstract_classes = IAPAlipay
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

View File

@ -1,3 +1,26 @@
/****************************************************************************
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"
@ -14,19 +37,19 @@ bool AdsAdmob::init()
return PluginUtils::initJavaPlugin(this, "org.cocos2dx.plugin.AdsAdmob");
}
void AdsAdmob::initAppInfo(TAppInfo appInfo)
void AdsAdmob::configDeveloperInfo(TAdsDeveloperInfo appInfo)
{
ProtocolAds::initAppInfo(appInfo);
ProtocolAds::configDeveloperInfo(appInfo);
}
void AdsAdmob::showBannerAd(EBannerPos pos, int sizeEnum)
void AdsAdmob::showAds(AdsType type, int sizeEnum, AdsPos pos)
{
ProtocolAds::showBannerAd(pos, sizeEnum);
ProtocolAds::showAds(type, sizeEnum, pos);
}
void AdsAdmob::hideBannerAd()
void AdsAdmob::hideAds(AdsType type)
{
ProtocolAds::hideBannerAd();
ProtocolAds::hideAds(type);
}
const char* AdsAdmob::getSDKVersion()

View File

@ -1,3 +1,26 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.HashSet;
@ -20,18 +43,17 @@ public class AdsAdmob implements AdsAdapter {
private static final String LOG_TAG = "AdsAdmob";
private static Activity mContext = null;
private static boolean bDebug = false;
// private static Handler mHandler = null;
// private static AdsAdmob mAdapter = null;
private static AdsAdmob mAdapter = null;
private AdView adView = null;
private String mPublishID = "";
private Set<String> mTestDevices = null;
private WindowManager mWm = null;
private static final int SIZE_BANNER = 0;
private static final int SIZE_IABMRect = 1;
private static final int SIZE_IABBanner = 2;
private static final int SIZE_IABLeaderboard = 3;
private static final int ADMOB_SIZE_BANNER = 0;
private static final int ADMOB_SIZE_IABMRect = 1;
private static final int ADMOB_SIZE_IABBanner = 2;
private static final int ADMOB_SIZE_IABLeaderboard = 3;
protected static void LogE(String msg, Exception e) {
Log.e(LOG_TAG, msg, e);
@ -46,7 +68,7 @@ public class AdsAdmob implements AdsAdapter {
public AdsAdmob(Context context) {
mContext = (Activity) context;
//mAdapter = this;
mAdapter = this;
}
@Override
@ -60,9 +82,9 @@ public class AdsAdmob implements AdsAdapter {
}
@Override
public void initAppInfo(Hashtable<String, String> appInfo) {
public void configDeveloperInfo(Hashtable<String, String> devInfo) {
try {
mPublishID = appInfo.get("AdmobID");
mPublishID = devInfo.get("AdmobID");
LogD("init AppInfo : " + mPublishID);
} catch (Exception e) {
LogE("initAppInfo, The format of appInfo is wrong", e);
@ -70,7 +92,38 @@ public class AdsAdmob implements AdsAdapter {
}
@Override
public void showBannerAd(int pos, int sizeEnum) {
public void showAds(int adsType, int sizeEnum, int pos) {
switch (adsType) {
case InterfaceAds.ADS_TYPE_BANNER:
showBannerAd(sizeEnum, pos);
break;
case InterfaceAds.ADS_TYPE_FULL_SCREEN:
LogD("Now not support full screen view in Admob");
break;
default:
break;
}
}
@Override
public void spendPoints(int points) {
// do nothing, Admob don't have this function
}
@Override
public void hideAds(int adsType) {
switch (adsType) {
case InterfaceAds.ADS_TYPE_BANNER:
hideBannerAd();
break;
case InterfaceAds.ADS_TYPE_FULL_SCREEN:
break;
default:
break;
}
}
private void showBannerAd(int sizeEnum, int pos) {
final int curPos = pos;
final int curSize = sizeEnum;
@ -89,13 +142,17 @@ public class AdsAdmob implements AdsAdapter {
AdSize size = AdSize.BANNER;
switch (curSize) {
case AdsAdmob.SIZE_BANNER:
case AdsAdmob.ADMOB_SIZE_BANNER:
size = AdSize.BANNER;
break;
case AdsAdmob.SIZE_IABMRect:
case AdsAdmob.ADMOB_SIZE_IABMRect:
size = AdSize.IAB_MRECT;
break;
case AdsAdmob.SIZE_IABBanner:
case AdsAdmob.ADMOB_SIZE_IABBanner:
size = AdSize.IAB_BANNER;
break;
case AdsAdmob.SIZE_IABLeaderboard:
case AdsAdmob.ADMOB_SIZE_IABLeaderboard:
size = AdSize.IAB_LEADERBOARD;
break;
default:
break;
@ -116,7 +173,7 @@ public class AdsAdmob implements AdsAdapter {
}
adView.loadAd(req);
adView.setAdListener(new AdmobAdListener());
adView.setAdListener(new AdmobAdsListener());
if (null == mWm) {
mWm = (WindowManager) mContext.getSystemService("window");
@ -126,8 +183,7 @@ public class AdsAdmob implements AdsAdapter {
});
}
@Override
public void hideBannerAd() {
private void hideBannerAd() {
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
@ -150,25 +206,25 @@ public class AdsAdmob implements AdsAdapter {
mTestDevices.add(deviceID);
}
private class AdmobAdListener implements AdListener {
private class AdmobAdsListener implements AdListener {
@Override
public void onDismissScreen(Ad arg0) {
LogD("onDismissScreen invoked");
InterfaceAds.dismissScreen();
InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!");
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
int errorNo = InterfaceAds.UNKNOWN_ERROR;
int errorNo = InterfaceAds.RESULT_CODE_UnknownError;
String errorMsg = "Unknow error";
switch (arg1) {
case NETWORK_ERROR:
errorNo = InterfaceAds.NETWORK_ERROR;
errorNo = InterfaceAds.RESULT_CODE_NetworkError;
errorMsg = "Network error";
break;
case INVALID_REQUEST:
errorNo = InterfaceAds.REQUESTING_ERROR;
errorNo = InterfaceAds.RESULT_CODE_NetworkError;
errorMsg = "The ad request is invalid";
break;
case NO_FILL:
@ -178,7 +234,7 @@ public class AdsAdmob implements AdsAdapter {
break;
}
LogD("failed to receive ad : " + errorNo + " , " + errorMsg);
InterfaceAds.failedToReceiveAd(errorNo, errorMsg);
InterfaceAds.onAdsResult(mAdapter, errorNo, errorMsg);
}
@Override
@ -189,13 +245,13 @@ public class AdsAdmob implements AdsAdapter {
@Override
public void onPresentScreen(Ad arg0) {
LogD("onPresentScreen invoked");
InterfaceAds.presentScreen();
InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!");
}
@Override
public void onReceiveAd(Ad arg0) {
LogD("onReceiveAd invoked");
InterfaceAds.receiveAd();
InterfaceAds.onAdsResult(mAdapter, InterfaceAds.RESULT_CODE_AdsReceived, "Ads request received success!");
}
}
}

View File

@ -1,3 +1,26 @@
/****************************************************************************
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__
@ -17,7 +40,7 @@ public:
virtual bool init();
/**
@brief initialize the developer info
@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
@ -28,7 +51,7 @@ public:
@warning Must invoke this interface before other interfaces.
And invoked only once.
*/
virtual void initDeveloperInfo(TDeveloperInfo devInfo);
virtual void configDeveloperInfo(TIAPDeveloperInfo devInfo);
/**
@brief pay for product

View File

@ -1,3 +1,26 @@
/****************************************************************************
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"
@ -18,7 +41,7 @@ bool IAPAlipay::init()
}
/**
@brief initialize the developer info
@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
@ -29,9 +52,9 @@ bool IAPAlipay::init()
@warning Must invoke this interface before other interfaces.
And invoked only once.
*/
void IAPAlipay::initDeveloperInfo(TDeveloperInfo devInfo)
void IAPAlipay::configDeveloperInfo(TIAPDeveloperInfo devInfo)
{
ProtocolIAP::initDeveloperInfo(devInfo);
ProtocolIAP::configDeveloperInfo(devInfo);
}
/**

View File

@ -1,3 +1,26 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.net.URLEncoder;
@ -51,7 +74,7 @@ public class IAPAlipay implements IAPAdapter {
}
@Override
public void initDeveloperInfo(Hashtable<String, String> cpInfo) {
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
LogD("initDeveloperInfo invoked " + cpInfo.toString());
try {
PartnerConfig.PARTNER = cpInfo.get("AlipayPartner");
@ -312,7 +335,7 @@ public class IAPAlipay implements IAPAdapter {
}
private static void payResult(int ret, String msg) {
InterfaceIAP.payResult(ret, msg);
InterfaceIAP.onPayResult(mAdapter, ret, msg);
LogD("Alipay result : " + ret + " msg : " + msg);
}
}

View File

@ -1,3 +1,26 @@
/****************************************************************************
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__

View File

@ -1,3 +1,26 @@
/****************************************************************************
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 <android/log.h>

View File

@ -1,3 +1,26 @@
/****************************************************************************
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"

View File

@ -1,61 +0,0 @@
#include "AnalyticsFlurry.h"
namespace cocos2d { namespace plugin {
PLUGIN_REGISTER_IMPL(AnalyticsFlurry)
AnalyticsFlurry::~AnalyticsFlurry()
{
}
bool AnalyticsFlurry::init()
{
return true;
}
void AnalyticsFlurry::setReportLocation(bool enabled)
{
}
void AnalyticsFlurry::logPageView()
{
}
void AnalyticsFlurry::setVersionName(const char* versionName)
{
}
void AnalyticsFlurry::setAge(int age)
{
}
void AnalyticsFlurry::setGender(Gender gender)
{
}
void AnalyticsFlurry::setUserId(const char* userId)
{
}
void AnalyticsFlurry::setUseHttps(bool useHttps)
{
}
void AnalyticsFlurry::logTimedEventBegin(const char* eventId)
{
}
void AnalyticsFlurry::logTimedEventBegin(const char* eventId, LogEventParamMap* paramMap)
{
}
}} // namespace cocos2d { namespace plugin {

View File

@ -1,3 +1,26 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;

View File

@ -1,3 +1,26 @@
/****************************************************************************
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__
@ -17,7 +40,7 @@ public:
virtual bool init();
/**
@brief initialize the developer info
@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
@ -26,7 +49,7 @@ public:
@warning Must invoke this interface before other interfaces.
And invoked only once.
*/
virtual void initDeveloperInfo(TDeveloperInfo devInfo);
virtual void configDeveloperInfo(TIAPDeveloperInfo devInfo);
/**
@brief pay for product

View File

@ -1,3 +1,26 @@
/****************************************************************************
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"
@ -18,7 +41,7 @@ bool IAPNd91::init()
}
/**
@brief initialize the developer info
@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
@ -27,9 +50,9 @@ bool IAPNd91::init()
@warning Must invoke this interface before other interfaces.
And invoked only once.
*/
void IAPNd91::initDeveloperInfo(TDeveloperInfo devInfo)
void IAPNd91::configDeveloperInfo(TIAPDeveloperInfo devInfo)
{
ProtocolIAP::initDeveloperInfo(devInfo);
ProtocolIAP::configDeveloperInfo(devInfo);
}
/**

View File

@ -1,3 +1,26 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;
@ -21,6 +44,7 @@ public class IAPNd91 implements IAPAdapter {
private static final String LOG_TAG = "IAPNd91";
private static Activity mContext = null;
private static IAPNd91 mNd91 = null;
private static boolean bDebug = false;
private static Hashtable<String, String> curProductInfo = null;
@ -37,10 +61,11 @@ public class IAPNd91 implements IAPAdapter {
public IAPNd91(Context context) {
mContext = (Activity) context;
mNd91 = this;
}
@Override
public void initDeveloperInfo(Hashtable<String, String> cpInfo) {
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
LogD("initDeveloperInfo invoked " + cpInfo.toString());
final Hashtable<String, String> curCPInfo = cpInfo;
PluginWrapper.runOnMainThread(new Runnable() {
@ -125,7 +150,7 @@ public class IAPNd91 implements IAPAdapter {
}
private static void payResult(int ret, String msg) {
InterfaceIAP.payResult(ret, msg);
InterfaceIAP.onPayResult(mNd91, ret, msg);
LogD("Nd91 result : " + ret + " msg : " + msg);
}

View File

@ -0,0 +1,76 @@
/****************************************************************************
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 <map>
#include <string>
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__ */

View File

@ -0,0 +1,60 @@
[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

View File

@ -0,0 +1,55 @@
#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 {

View File

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

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginTwitter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>android</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/platform/android</locationURI>
</link>
<link>
<name>include</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/include</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

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

View File

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

View File

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

View File

@ -0,0 +1,20 @@
# 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

View File

@ -0,0 +1,29 @@
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)

View File

@ -0,0 +1,7 @@
# 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

View File

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

View File

View File

@ -0,0 +1 @@
62d02b6f0d450b3b64d061280594018742ddcd27

View File

@ -0,0 +1,9 @@
package org.cocos2dx.plugin;
public interface Consts {
public static int EGETTING_ACCESS_TOKEN =0;
public static int EUSER_CANCELED = 1;
public static int EGETTING_REQUEST_TOKEN=2;
public static int EFAILED_OPENING_AUTHORIZATION_PAGE=3;
public static int EPAGE_ERROR =4;
}

View File

@ -0,0 +1,191 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;
import org.cocos2dx.plugin.InterfaceSocial.ShareAdapter;
import org.cocos2dx.plugin.TwitterApp.TwDialogListener;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
public class SocialTwitter implements ShareAdapter {
private static final String LOG_TAG = "SocialTwitter";
private static Activity mContext = null;
private static ShareAdapter mSocialAdapter = null;
protected static boolean bDebug = false;
private static String CONSUMER_KEY="";
private static String CONSUMER_SECRET="";
private static TwitterApp mTwitter = null;
private static boolean isInitialized = false;
private static Hashtable<String, String> mShareInfo = null;
public static String KEY_TEXT="SharedText";
public static String KEY_IMAGE_PATH = "SharedImagePath";
protected static void LogE(String msg, Exception e) {
Log.e(LOG_TAG, msg, e);
e.printStackTrace();
}
protected static void LogD(String msg) {
if (bDebug) {
Log.d(LOG_TAG, msg);
}
}
public SocialTwitter(Context context) {
mContext = (Activity) context;
mSocialAdapter = this;
}
@Override
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
LogD("initDeveloperInfo invoked " + cpInfo.toString());
try {
SocialTwitter.CONSUMER_KEY = cpInfo.get("TwitterKey");
SocialTwitter.CONSUMER_SECRET = cpInfo.get("TwitterSecret");
LogD("key : " + SocialTwitter.CONSUMER_KEY);
LogD("secret : " + SocialTwitter.CONSUMER_SECRET);
if(isInitialized){
return;
}
isInitialized = true;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
mTwitter = new TwitterApp(PluginWrapper.getContext(), SocialTwitter.CONSUMER_KEY, SocialTwitter.CONSUMER_SECRET);
mTwitter.setListener(mTwLoginDialogListener);
}
});
} catch (Exception e) {
LogE("Developer info is wrong!", e);
}
}
@Override
public void share(Hashtable<String, String> info) {
LogD("share invoked " + info.toString());
mShareInfo = info;
if (! networkReachable()) {
shareResult(InterfaceSocial.SHARERESULT_FAIL, "Network error!");
return;
}
if (! isInitialized) {
shareResult(InterfaceSocial.SHARERESULT_FAIL, "Initialize failed!");
return;
}
// need login
if(!mTwitter.hasAccessToken()){
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
mTwitter.authorize();
}
});
return;
}
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
SocialTwitter.sendToTwitter();
}
});
}
@Override
public void setDebugMode(boolean debug) {
bDebug = debug;
}
@Override
public String getSDKVersion() {
return "Unknown version";
}
private boolean networkReachable() {
boolean bRet = false;
try {
ConnectivityManager conn = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = conn.getActiveNetworkInfo();
bRet = (null == netInfo) ? false : netInfo.isAvailable();
} catch (Exception e) {
LogE("Fail to check network status", e);
}
LogD("NetWork reachable : " + bRet);
return bRet;
}
private static void shareResult(int ret, String msg) {
InterfaceSocial.onShareResult(mSocialAdapter, ret, msg);
LogD("SocialTwitter result : " + ret + " msg : " + msg);
}
private static final TwDialogListener mTwLoginDialogListener = new TwDialogListener() {
@Override
public void onError(int flag, String value) {
LogD("Twitter connection failed!");
shareResult(InterfaceSocial.SHARERESULT_FAIL, value);
}
@Override
public void onComplete(String value) {
SocialTwitter.sendToTwitter();
}
};
private static void sendToTwitter() {
String text = mShareInfo.get(KEY_TEXT);
String imagePath = mShareInfo.get(KEY_IMAGE_PATH);
try {
if(imagePath != null && imagePath.length() > 0){
mTwitter.updateStatus(text, imagePath);
}else{
mTwitter.updateStatus(text);
}
LogD("Posted to Twitter!");
shareResult(InterfaceSocial.SHARERESULT_SUCCESS, "Share succeed!");
} catch (Exception e) {
LogD("Post to Twitter failed!");
shareResult(InterfaceSocial.SHARERESULT_FAIL, "Unknown error!");
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,235 @@
/**
* @author Lorensius W. L. T <lorenz@londatiga.net>
*
* http://www.londatiga.net
*/
package org.cocos2dx.plugin;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import oauth.signpost.OAuthProvider;
import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import twitter4j.StatusUpdate;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.auth.AccessToken;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Window;
public class TwitterApp {
private Twitter mTwitter;
private TwitterSession mSession;
private AccessToken mAccessToken;
private CommonsHttpOAuthConsumer mHttpOauthConsumer;
private OAuthProvider mHttpOauthprovider;
private String mConsumerKey;
private String mSecretKey;
private ProgressDialog mProgressDlg;
private TwDialogListener mListener;
private Context context;
private boolean mInit = true;
private static final String LOG_TAG = "TwitterApp";
public static final String CALLBACK_URL = "twitterapp://connect";
protected static void LogE(String msg, Exception e) {
Log.e(LOG_TAG, msg, e);
e.printStackTrace();
}
protected static void LogD(String msg) {
if (SocialTwitter.bDebug) {
Log.d(LOG_TAG, msg);
}
}
public TwitterApp(Context context, String consumerKey, String secretKey) {
this.context = context;
mTwitter = new TwitterFactory().getInstance();
mSession = new TwitterSession(context);
mProgressDlg = new ProgressDialog(context);
mProgressDlg.setCancelable(false);
mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
mConsumerKey = consumerKey;
mSecretKey = secretKey;
mHttpOauthConsumer = new CommonsHttpOAuthConsumer(mConsumerKey, mSecretKey);
mHttpOauthprovider = new DefaultOAuthProvider("https://twitter.com/oauth/request_token",
"https://twitter.com/oauth/access_token",
"https://twitter.com/oauth/authorize");
mAccessToken = mSession.getAccessToken();
configureToken();
}
public void setListener(TwDialogListener listener) {
mListener = listener;
}
private void configureToken() {
if (mAccessToken != null) {
if (mInit) {
mTwitter.setOAuthConsumer(mConsumerKey, mSecretKey);
mInit = false;
}
mTwitter.setOAuthAccessToken(mAccessToken);
}
}
public boolean hasAccessToken() {
return (mAccessToken == null) ? false : true;
}
public void resetAccessToken() {
if (mAccessToken != null) {
mSession.resetAccessToken();
mAccessToken = null;
}
}
public String getUsername() {
return mSession.getUsername();
}
public void updateStatus(String status) throws Exception {
try {
mTwitter.updateStatus(status);
} catch (TwitterException e) {
throw e;
}
}
public void updateStatus(String status, String imagePath) throws Exception {
StatusUpdate update = new StatusUpdate(status);
update.setMedia(new File(imagePath));
try {
mTwitter.updateStatus(update);
} catch (TwitterException e) {
throw e;
}
}
public void authorize() {
mProgressDlg.setMessage("Initializing ...");
mProgressDlg.show();
new Thread() {
@Override
public void run() {
String authUrl = "";
int what = 1;
try {
authUrl = mHttpOauthprovider.retrieveRequestToken(mHttpOauthConsumer, CALLBACK_URL);
what = 0;
LogD("Request token url " + authUrl);
} catch (Exception e) {
LogD("Failed to get request token");
e.printStackTrace();
}
mHandler.sendMessage(mHandler.obtainMessage(what, 1, 0, authUrl));
}
}.start();
}
public void processToken(String callbackUrl) {
mProgressDlg.setMessage("Finalizing ...");
mProgressDlg.show();
final String verifier = getVerifier(callbackUrl);
new Thread() {
@Override
public void run() {
int what = 1;
try {
mHttpOauthprovider.retrieveAccessToken(mHttpOauthConsumer, verifier);
mAccessToken = new AccessToken(mHttpOauthConsumer.getToken(), mHttpOauthConsumer.getTokenSecret());
configureToken();
User user = mTwitter.verifyCredentials();
mSession.storeAccessToken(mAccessToken, user.getName());
what = 0;
} catch (Exception e){
LogD("Error getting access token");
e.printStackTrace();
}
mHandler.sendMessage(mHandler.obtainMessage(what, 2, 0));
}
}.start();
}
private String getVerifier(String callbackUrl) {
String verifier = "";
try {
callbackUrl = callbackUrl.replace("twitterapp", "http");
URL url = new URL(callbackUrl);
String query = url.getQuery();
String array[] = query.split("&");
for (String parameter : array) {
String v[] = parameter.split("=");
if (URLDecoder.decode(v[0]).equals(oauth.signpost.OAuth.OAUTH_VERIFIER)) {
verifier = URLDecoder.decode(v[1]);
break;
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return verifier;
}
private void showLoginDialog(String url) {
final TwDialogListener listener = new TwDialogListener() {
@Override
public void onComplete(String value) {
processToken(value);
}
@Override
public void onError(int flag, String value) {
mListener.onError(Consts.EFAILED_OPENING_AUTHORIZATION_PAGE, "Failed opening authorization page");
}
};
new TwitterDialog(context, url, listener).show();
}
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
mProgressDlg.dismiss();
if (msg.what == 1) {
if (msg.arg1 == 1)
mListener.onError(Consts.EGETTING_REQUEST_TOKEN, "Error getting request token");
else
mListener.onError(Consts.EGETTING_ACCESS_TOKEN, "Error getting access token");
}else {
if (msg.arg1 == 1)
showLoginDialog((String) msg.obj);
else
mListener.onComplete("");
}
}
};
public interface TwDialogListener {
public void onComplete(String value);
public void onError(int flag, String value);
}
}

View File

@ -0,0 +1,182 @@
/**
* Modified from FbDialog from Facebook SDK
*
* Lorensius W. L. T <lorenz@londatiga.net>
*/
package org.cocos2dx.plugin;
import org.cocos2dx.plugin.TwitterApp.TwDialogListener;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.ViewGroup;
import android.view.Window;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
public class TwitterDialog extends Dialog {
static final FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
static final int MARGIN = 4;
static final int PADDING = 2;
private String mUrl;
private TwDialogListener mListener;
private ProgressDialog mSpinner;
private WebView mWebView;
private LinearLayout mContent;
private TextView mTitle;
private static final String LOG_TAG = "Twitter-WebView";
protected static void LogD(String msg) {
if (SocialTwitter.bDebug) {
Log.d(LOG_TAG, msg);
}
}
public TwitterDialog(Context context, String url, TwDialogListener listener) {
super(context);
mUrl = url;
mListener = listener;
setOnCancelListener(mCancelListener);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSpinner = new ProgressDialog(getContext());
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mSpinner.setCancelable(false);
mContent = new LinearLayout(getContext());
mContent.setOrientation(LinearLayout.VERTICAL);
setUpTitle();
setUpWebView();
Display display = getWindow().getWindowManager().getDefaultDisplay();
double[] dimensions = new double[2];
if (display.getWidth() < display.getHeight()) {
dimensions[0] = 0.87 * display.getWidth();
dimensions[1] = 0.82 * display.getHeight();
} else {
dimensions[0] = 0.75 * display.getWidth();
dimensions[1] = 0.75 * display.getHeight();
}
addContentView(mContent, new FrameLayout.LayoutParams((int) dimensions[0], (int) dimensions[1]));
}
private void setUpTitle() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Drawable icon = getContext().getResources().getDrawable(R.drawable.twitter_icon);
mTitle = new TextView(getContext());
mTitle.setText("Twitter");
mTitle.setTextColor(Color.WHITE);
mTitle.setTypeface(Typeface.DEFAULT_BOLD);
mTitle.setBackgroundColor(0xFFbbd7e9);
mTitle.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
mTitle.setCompoundDrawablePadding(MARGIN + PADDING);
// mTitle.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
mTitle.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
mContent.addView(mTitle);
}
private void setUpWebView() {
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new TwitterWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
private class TwitterWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LogD("Redirecting URL " + url);
if (url.startsWith(TwitterApp.CALLBACK_URL)) {
mListener.onComplete(url);
TwitterDialog.this.dismiss();
return true;
} else if (url.startsWith("authorize")) {
return false;
}
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
LogD("Page error: " + description);
super.onReceivedError(view, errorCode, description, failingUrl);
mListener.onError(Consts.EPAGE_ERROR, description);
TwitterDialog.this.dismiss();
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
LogD("Loading URL: " + url);
super.onPageStarted(view, url, favicon);
mSpinner.show();
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String title = mWebView.getTitle();
if (title != null && title.length() > 0) {
mTitle.setText(title);
}
mSpinner.dismiss();
}
}
private DialogInterface.OnCancelListener mCancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mSpinner.dismiss();
mListener.onError(Consts.EUSER_CANCELED, "User canceled!");
}
};
}

View File

@ -0,0 +1,56 @@
/**
* @author Lorensius W. L. T <lorenz@londatiga.net>
*
* http://www.londatiga.net
*/
package org.cocos2dx.plugin;
import twitter4j.auth.AccessToken;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class TwitterSession {
private SharedPreferences sharedPref;
private Editor editor;
private static final String TWEET_AUTH_KEY = "auth_key";
private static final String TWEET_AUTH_SECRET_KEY = "auth_secret_key";
private static final String TWEET_USER_NAME = "user_name";
private static final String SHARED = "Twitter_Preferences";
public TwitterSession(Context context) {
sharedPref = context.getSharedPreferences(SHARED, Context.MODE_PRIVATE);
editor = sharedPref.edit();
}
public void storeAccessToken(AccessToken accessToken, String username) {
editor.putString(TWEET_AUTH_KEY, accessToken.getToken());
editor.putString(TWEET_AUTH_SECRET_KEY, accessToken.getTokenSecret());
editor.putString(TWEET_USER_NAME, username);
editor.commit();
}
public void resetAccessToken() {
editor.putString(TWEET_AUTH_KEY, null);
editor.putString(TWEET_AUTH_SECRET_KEY, null);
editor.putString(TWEET_USER_NAME, null);
editor.commit();
}
public String getUsername() {
return sharedPref.getString(TWEET_USER_NAME, "");
}
public AccessToken getAccessToken() {
String token = sharedPref.getString(TWEET_AUTH_KEY, null);
String tokenSecret = sharedPref.getString(TWEET_AUTH_SECRET_KEY, null);
if (token != null && tokenSecret != null)
return new AccessToken(token, tokenSecret);
else
return null;
}
}

View File

@ -1,3 +1,26 @@
/****************************************************************************
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__

View File

@ -1,3 +1,26 @@
/****************************************************************************
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 <android/log.h>

View File

@ -1,3 +1,26 @@
/****************************************************************************
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"
@ -39,6 +62,7 @@ void AnalyticsUmeng::startSession(const char* appKey)
return;
}
NSString* pKey = [NSString stringWithUTF8String:appKey];
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
[MobClick startWithAppkey:pKey];
}
@ -288,6 +312,7 @@ void AnalyticsUmeng::startSession(const char* appKey, UmengReportPolicy policy,
NSString* key = [NSString stringWithUTF8String:appKey];
NSString* channel = [NSString stringWithUTF8String:channelId];
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
[MobClick startWithAppkey:key reportPolicy:(ReportPolicy)policy channelId:channel];
}

View File

@ -3,348 +3,349 @@
// MobClick
//
// Created by Aladdin on 2010-03-25.
// Updated by Minghua on 2012-09-11.
// Updated by Minghua on 2013-04-01.
// Copyright 2010-2012 Umeng.com . All rights reserved.
// Version 2.1.0 , updated_at 2012-09-11.
// Version 2.2.0.OpenUDID, updated_at 2013-04-01.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#define UMOnlineConfigDidFinishedNotification @"OnlineConfigDidFinishedNotification"
#define XcodeAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
typedef enum {
REALTIME = 0, //实时发送
BATCH = 1, //启动发送
SENDDAILY = 4, //每日发送
SENDWIFIONLY = 5 //仅在WIFI下启动时发送
SENDWIFIONLY = 5, //仅在WIFI下启动时发送
SEND_INTERVAL = 6, //按最小间隔发送
SEND_ON_EXIT = 7 //退出或进入后台时发送
} ReportPolicy;
@protocol MobClickDelegate;
@class CLLocation;
/** MobClick是统计的核心类本身不需要实例化所有方法以类方法的形式提供.
REALTIME,BATCH,SENDDAILY,SENDWIFIONLY,SEND_INTERVAL,SEND_ON_EXIT
REALTIME,SENDWIFIONLY DEBUG模式下生效release模式会自动改成BATCH
http://blog.umeng.com/index.php/2012/12/0601/
SEND_INTERVAL ,10,10 86400() 10
SEND_ON_EXIT 退,App运行过程中不发送
iOS > 4.0, iOS < 4.0 BATCH
*/
@interface MobClick : NSObject <UIAlertViewDelegate> {
@private
id _internal;
}
#pragma mark basics
//开启友盟统计,以BATCH方式发送log.
+ (void)startWithAppkey:(NSString *)appKey;
// channelId 为nil或@""时,默认会被被当作@"App Store"渠道
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
/*
app版本信息CFBundleVersion里取,build version,xcode3工程兼容.
xcode4版本保持一致使
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
[MobClick setAppVersion:version];
*/
///---------------------------------------------------------------------------------------
/// @name 设置
///---------------------------------------------------------------------------------------
/** 设置app版本号。由于历史原因需要和xcode3工程兼容,友盟提取的是Build号(CFBundleVersion),如果需要和App Store上的版本一致,需要调用此方法。
@param appVersion `XcodeAppVersion`.
@return void.
*/
+ (void)setAppVersion:(NSString *)appVersion;
+ (NSString *)getAgentVersion; //获取友盟sdk 版本号
/*方法名:
* setCrashReportEnabled:(BOOL)value
*:
* umeng SDK crash log
*:
* (BOOL)value:YES
* NO,umeng SDK crash log,setDelegate方法之前调用
*/
/** 开启CrashReport收集, 默认是开启状态.
@param value NO,CrashReport收集.
@return void.
*/
+ (void)setCrashReportEnabled:(BOOL)value;
/*方法名:
* setLogEnabled:(BOOL)value
*:
* sdk的log信息
*:
* (BOOL)value:NO
* YES,umeng SDK log信息,release产品时要设置回NO
/** 设置是否打印sdk的log信息,默认不开启
@param value YES,umeng SDK log信息,release产品时要设置回NO.
@return .
@exception .
*/
+ (void)setLogEnabled:(BOOL)value;
/*方法名:
* logPageView:seconds:
*:
* view打开多长时间.
*
*:
* pageName NSString *
* seconds int型
*
*
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#8
*/
///---------------------------------------------------------------------------------------
/// @name 开启统计
///---------------------------------------------------------------------------------------
/** 开启友盟统计,默认以BATCH方式发送log.
@param appKey appKey.
@param reportPolicy .
@param channelId ,nil或@"",@"App Store"
@return void
*/
+ (void)startWithAppkey:(NSString *)appKey;
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
/** 当reportPolicy == SEND_INTERVAL 时设定log发送间隔
@param second ,10,86400().
@return void.
*/
+ (void)setLogSendInterval:(double)second;
///---------------------------------------------------------------------------------------
/// @name 页面计时
///---------------------------------------------------------------------------------------
/** 页面时长统计,记录某个view被打开多长时间,可以自己计时也可以调用beginLogPageView,endLogPageView自动计时
@param pageName view名称.
@param seconds int型.
@return void.
*/
+ (void)logPageView:(NSString *)pageName seconds:(int)seconds;
+ (void)beginLogPageView:(NSString *)pageName;
+ (void)endLogPageView:(NSString *)pageName;
#pragma mark event logs
/*方法名:
* event:(NSString *)eventId
* event:(NSString *)eventId label:(NSString *)label
* event:(NSString *)eventId acc:(NSInteger)accumulation
* event:(NSString *)eventId label:(NSString *)label acc:(NSInteger)accumulation
*:
* 使App管理后台的设置-> IDID即可
*
*:
* 便1
* label:ID添加该事件的分类标签统计ID进行统计和整理ID的不同的标签便
* accumulation:ID的某一分类标签进行累加
*
*: http://dev.umeng.com/doc/document_ana_ios.html#3
*/
//如果label为nil或@""时服务器端会生成一个unknown的默认label,
//为避免这种情况,2.0.0之后label为nil或@""时,label将被赋值为eventId
//详细文档参见 iOS统计分析SDK开发指南.html 或在线文档
//http://dev.umeng.com/doc/document_ana_ios.html#3
///---------------------------------------------------------------------------------------
/// @name 事件统计
///---------------------------------------------------------------------------------------
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
@param eventId Id.
@param label 便,nil或空字符串时后台会生成和eventId同名的标签.
@param accumulation ID的某一分类标签进行累加
@return void.
*/
+ (void)event:(NSString *)eventId; //等同于 event:eventId label:eventId;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId label:(NSString *)label; // label为nil或@""时,等同于 event:eventId label:eventId;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId acc:(NSInteger)accumulation;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId label:(NSString *)label acc:(NSInteger)accumulation;
/** 自定义事件,数量统计.
使App管理后台的设置-> IDID
*/
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
beginEvent,endEvent要配对使用,durations参数传递进来
@param eventId Id.
@param label 便,nil或空字符串时后台会生成和eventId同名的标签.
@param primarykey event_id一起标示一个唯一事件beginEvent和endEvent eventId primarykey
@param millisecond
@return void.
@warning event的attributes不能超过10个
eventIdattributes中key和value都不能使用空格和特殊字符eventIdattributes的key最大为128个bytes(12842)labelattributes的value最大为256个bytes(25684),
eventId超过的将抛弃不再发送
id ts du是保留字段eventId及key的名称
*/
+ (void)beginEvent:(NSString *)eventId;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)beginEvent:(NSString *)eventId label:(NSString *)label;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId label:(NSString *)label;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
//primarykey这个参数用于和event_id一起标示一个唯一事件并不会被统计
//对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey
//每个event的attributes不能超过10个
//eventId、attributes中key和value都不能使用空格和特殊字符且长度不能超过255个字符否则将截取前255个字符
//id ts du是保留字段不能作为eventId及key的名称
+ (void)beginEvent:(NSString *)eventId primarykey :(NSString *)keyName attributes:(NSDictionary *)attributes;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)endEvent:(NSString *)eventId primarykey:(NSString *)keyName;
//时间单位为毫秒 microseconds
+ (void)event:(NSString *)eventId durations:(int)microseconds;
+ (void)event:(NSString *)eventId label:(NSString *)label durations:(int)microseconds;
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)microseconds;
#pragma mark feedback Default GUI
/*方法名:
- * showFeedback:(UIViewController *)rootViewcontroller
- *:
- *
- *:
- * rootViewController:presentModalViewController方法来展示反馈界面
- * rootViewController非空
- *
- * 使SDK
- */
+ (void)showFeedback:(UIViewController *)rootViewController;
#pragma mark feedback data api
/*方法名:
* feedbackWithDictionary:(NSDictionary * )feedbackDict
*:
*
*:
* Dictionary中应该有以下三个键名:
* @"UMengFeedbackGender" @"UMengFeedbackAge" @"UMengFeedbackContent"
* :
* NSString类型的
* 1=> 2=>
*
* 1=>18(18),2=>18-24,3=>25-30,
* 4=>31-35,5=>36-40,6=>41-50,7=>51-59,8=>6060
*
*
*
*:
*
*
*
* 使SDK
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)feedbackWithDictionary:(NSDictionary *)feedbackDict;
#pragma mark check app update
/*方法名:
* checkUpdate
* checkUpdateWithTitle:CancelButtonTitle:OtherButtonTitle:
*:
* app是否有更新UIAlertView提示用户,app会跳转到您预先设置的网址
*
* app版本信息App Store.
* checkUpdate .
*
*:
* checkUpdate
* checkUpdate:cancelButtonTitle:otherButtonTitles: :
* title UIAlertView的title
* cancelTitle UIAlertView的cancelTitle
* otherTitle UIAlertView的otherTitle
*
* [MobClick setDelegate:reportPolicy:];
* MobClickDelegate的appUpdate方法
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#5
+ (void)event:(NSString *)eventId durations:(int)millisecond;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)event:(NSString *)eventId label:(NSString *)label durations:(int)millisecond;
/** 自定义事件,时长统计.
使App管理后台的设置-> IDID.
*/
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)millisecond;
///---------------------------------------------------------------------------------------
/// @name 按渠道自动更新
///---------------------------------------------------------------------------------------
/** 按渠道自动更新检测
app是否有更新UIAlertView提示用户,app会跳转到您预先设置的网址
app版本信息App Store.
MobClickDelegate的appUpdate方法
@param title UIAlertView的title.
@param cancelTitle UIAlertView的cancelTitle.
@param otherTitle UIAlertView的otherTitle.
@param delegate checkUpdate的对象.
@param callBackSelectorWithDictionary checkUpdate事件完成时此方法会被调用,app更新信息的字典被传回.
@return void.
*/
+ (void)checkUpdate;
/** 按渠道自动更新检测
*/
+ (void)checkUpdate:(NSString *)title cancelButtonTitle:(NSString *)cancelTitle otherButtonTitles:(NSString *)otherTitle;
/** 按渠道自动更新检测
*/
+ (void)checkUpdateWithDelegate:(id)delegate selector:(SEL)callBackSelectorWithDictionary;
#pragma mark online config params
/*方法名:
* updateOnlineConfig
*:
* 线,[NSUserDefaults standardUserDefaults].
* 线SDK端发送策略的功能
* 线.
*
*:
*
*
* [MobClick setDelegate:reportPolicy:];
* 使线
*
*:
*
*
*: http://dev.umeng.com/doc/document_ana_ios.html#6
///---------------------------------------------------------------------------------------
/// @name 在线参数
///---------------------------------------------------------------------------------------
/** 使用在线参数功能,可以让你动态修改应用中的参数值,
线,[NSUserDefaults standardUserDefaults],
线SDK端发送策略的功能,线.
[MobClick startWithAppkey:];
线UMOnlineConfigDidFinishedNotification
@param .
@return void.
*/
+ (void)updateOnlineConfig;
/*方法名:
* getConfigParams
* getConfigParams:
*:
* [NSUserDefaults standardUserDefaults]线.
* key的值线.
*
*:
* NSString *
*
* [NSUserDefaults standardUserDefaults],
* updateOnlineConfig方法要先在app启动时被调用
*
*:
* (NSString *) (NSDictionary *)
*
*: http://dev.umeng.com/doc/document_ana_ios.html#6
/** 从[NSUserDefaults standardUserDefaults]获取缓存的在线参数的数值
key的值线.
updateOnlineConfig才能使用,线UMOnlineConfigDidFinishedNotification
@param key
@return (NSString *) .
*/
+ (NSString *)getConfigParams:(NSString *)key;
/** 从[NSUserDefaults standardUserDefaults]获取缓存的在线参数
@return (NSDictionary *).
*/
+ (NSDictionary *)getConfigParams;
// 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
// 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
///---------------------------------------------------------------------------------------
/// @name 地理位置设置
///---------------------------------------------------------------------------------------
/** 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
CoreLocation.framework #import <CoreLocation/CoreLocation.h>
@param latitude .
@param longitude .
@param location CLLocation *
@return void
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
/** 为了更精确的统计用户地理位置,可以调用此方法传入经纬度信息
*/
+ (void)setLocation:(CLLocation *)location;
#pragma mark helper
/*方法名:
* isJailbroken
*:
* apt和Cydia.app的path来判断
*:
*
*
*
*/
///---------------------------------------------------------------------------------------
/// @name helper方法
///---------------------------------------------------------------------------------------
#pragma mark utils api
// 类方法,判断当前设备是否已经越狱
/** 判断设备是否越狱,判断方法根据 apt和Cydia.app的path来判断
*/
+ (BOOL)isJailbroken;
// 类方法判断你的App是否被破解
/** 判断你的App是否被破解
*/
+ (BOOL)isPirated;
#pragma mark DEPRECATED methods from version 1.7
/*方法名:
* setDelegate:(id<MobClickDelegate>)delegate
* setDelegate:(id<MobClickDelegate>)delegate reportPolicy:(ReportPolicy)rp;
*:
* startWithAppkey:(NSString *)appKey ;
* MobClickDelegate实现使.
* MobClick代理MobClick实例appLaunched方法前
*:
* delegate:MobClickDelegate协议的实例
* ReportPolicy:
* 1.BATCH :
* 2.REALTIME :event
*
*/
/** 设置MobClick代理,已经startWithAppkey:所取代,不要再使用,原有代码可以删除
*/
+ (void)setDelegate:(id)delegate;
+ (void)setDelegate:(id)delegate reportPolicy:(ReportPolicy)rp;
/*方法名:
* appLaunched
*:
* setDelegate: setDelegate: reportPolicy:
*:
*
*
* 1.6.7.
*/
/** 记录启动时间,模块开始启用,不要再使用,原有代码可以删除
*/
+ (void)appLaunched;
/*方法名:
* appTerminated
*:
*
*:
*
* 1.6.7.
/** 记录软件终止时间,模块终止,不要再使用,原有代码可以删除
*/
+ (void)appTerminated;
/*
SDK内部使用的监听方法App启动退
[MobClick startWithAppkey:]application:didFinishLaunchingWithOptions:
App启动和退出事件application:didFinishLaunchingWithOptions:[MobClick startWithAppkey:]
App的启动事件可能会无法监听[MobClick startSession:nil]session
/** 友盟模块启动
[MobClick startWithAppkey:]application:didFinishLaunchingWithOptions:
App启动和退出事件application:didFinishLaunchingWithOptions:[MobClick startWithAppkey:]
App的启动事件可能会无法监听[MobClick startSession:nil]session
app里app使用不到.
*/
+ (void)startSession:(NSNotification *)notification;
/** 获取友盟sdk 版本号,目前友盟模块启动时自动调用,不要再使用,原有代码可以删除
*/
+ (NSString *)getAgentVersion; //
@end
//此协议的三个方法不再建议使用,建议用新方法代替
//+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
//+ (void)checkUpdate:(id)delegate selector:(SEL)callBackSelector;
/** MobClickDelegate protocol
使
+ (void)startWithAppkey:(NSString *)appKey reportPolicy:(ReportPolicy)rp channelId:(NSString *)cid;
+ (void)checkUpdate:(id)delegate selector:(SEL)callBackSelector;
*/
@protocol MobClickDelegate <NSObject>
@optional
/*方法名:
* - (NSString *)appKey;
*:
* AppkeyAppkey错误log进行记录
*:
* Appkey是从友盟后台注册新App得到的
*
*/
- (NSString *)appKey;
/*方法名:
* - (NSString *)channelId;
*:
* ChannelID
*:
* @"Apple Store",@"产品主页"
* 使
*
*/
- (NSString *)channelId;
/*方法名:
* - (void)appUpdate:(NSMutableDictionary *)updateInfo;
*:
*
*:
* [MobClick checkUpdate]appUpdate
* updateInfo是与此app版本信息相关的参数
*
*
*
*/
- (void)appUpdate:(NSDictionary *)appUpdateInfo;
@end

View File

@ -1 +1 @@
bf891cff30d0a838748b877ec96cded1e540e349
c61504f40c4fbe912ff1d74677edf29234eb192c

View File

@ -1,67 +0,0 @@
#include "AnalyticsUmeng.h"
namespace cocos2d { namespace plugin {
PLUGIN_REGISTER_IMPL(AnalyticsUmeng)
AnalyticsUmeng::~AnalyticsUmeng()
{
}
bool AnalyticsUmeng::init()
{
return true;
}
void AnalyticsUmeng::updateOnlineConfig()
{
}
const char* AnalyticsUmeng::getConfigParams(const char* key)
{
return "";
}
void AnalyticsUmeng::setDefaultReportPolicy(ReportPolicy ePolicy)
{
}
void AnalyticsUmeng::logEventWithLabel(const char* eventId, const char* label)
{
}
void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, const char* label)
{
}
void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, LogEventParamMap* paramMap /* = NULL */)
{
}
void AnalyticsUmeng::logTimedEventWithLabelBegin(const char* eventId, const char* label)
{
}
void AnalyticsUmeng::logTimedEventWithLabelEnd(const char* eventId, const char* label)
{
}
void AnalyticsUmeng::logTimedKVEventBegin(const char* eventId, const char* label, LogEventParamMap* paramMap)
{
}
void AnalyticsUmeng::logTimedKVEventEnd(const char* eventId, const char* label)
{
}
}} // namespace cocos2d { namespace plugin {

View File

@ -0,0 +1 @@
ac5e2e30a4c3ff07611e9c6260eaff84bf644135

View File

@ -1,6 +1,32 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import android.content.Context;
import android.util.Log;
@ -26,6 +52,7 @@ public class AnalyticsUmeng implements InterfaceAnalytics{
public AnalyticsUmeng(Context context) {
mContext = context;
MobclickAgent.setWrapper("Cocos2d-x", "1.0");
}
public boolean isValid() {
@ -78,7 +105,8 @@ public class AnalyticsUmeng implements InterfaceAnalytics{
@Override
public void logEvent(String eventId, Hashtable<String, String> paramMap) {
LogD("logEvent(eventId, paramMap) invoked!");
MobclickAgent.onEvent(mContext, eventId, paramMap);
HashMap<String, String> curParam = changeTableToMap(paramMap);
MobclickAgent.onEvent(mContext, eventId, curParam);
}
@Override
@ -165,7 +193,8 @@ public class AnalyticsUmeng implements InterfaceAnalytics{
LogD("logEventWithDuration(eventId, duration, paramMap) invoked!");
if (!isValid()) return;
try{
MobclickAgent.onEventDuration(mContext, eventId, paramMap, duration);
HashMap<String, String> curMap = changeTableToMap(paramMap);
MobclickAgent.onEventDuration(mContext, eventId, curMap, duration);
} catch(Exception e){
LogE("Exception in logEventWithDuration,eventId,duration,paramMap", e);
}
@ -195,7 +224,8 @@ public class AnalyticsUmeng implements InterfaceAnalytics{
LogD("logTimedKVEventBegin invoked!");
if (!isValid()) return;
try{
MobclickAgent.onKVEventBegin(mContext, eventId, paramMap, label);
HashMap<String, String> curMap = changeTableToMap(paramMap);
MobclickAgent.onKVEventBegin(mContext, eventId, curMap, label);
} catch(Exception e){
LogE("Exception in logTimedKVEventBegin", e);
}
@ -210,4 +240,16 @@ public class AnalyticsUmeng implements InterfaceAnalytics{
LogE("Exception in logTimedKVEventEnd", e);
}
}
private HashMap<String, String> changeTableToMap(Hashtable<String, String> param) {
HashMap<String, String> retParam = new HashMap<String, String>();
for(Iterator<String> it = param.keySet().iterator(); it.hasNext(); ) {
String key = it.next();
String value = param.get(key);
retParam.put(key, value);
}
return retParam;
}
}

View File

@ -1,3 +1,26 @@
/****************************************************************************
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 "PluginManager.h"
#include <map>
#include <string>

View File

@ -1,3 +1,26 @@
/****************************************************************************
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 "RegisterPlugin.h"
#include "PluginManager.h"

View File

@ -1,3 +1,26 @@
/****************************************************************************
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_PLUGINMANAGER_H__
#define __CCX_PLUGINMANAGER_H__

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