Merge pull request from cocos2d/develop

This commit is contained in:
Rene Klacan 2013-06-11 01:06:12 +02:00
commit f31a258c01
170 changed files with 6478 additions and 1547 deletions

View File

@ -24,6 +24,7 @@ Developers:
carlomorgantinizynga carlomorgantinizynga
CCLabelTTF supports for shadow and stroke CCLabelTTF supports for shadow and stroke
Adding CCLabelTTF::createWithFontDefinition.
James Gregory (j4m3z0r, Zynga) James Gregory (j4m3z0r, Zynga)
Maintainer of Emscripten port. Maintainer of Emscripten port.
@ -183,6 +184,7 @@ Developers:
Simpler, correct handling of spritesheet sources for CCScale9Sprite. Simpler, correct handling of spritesheet sources for CCScale9Sprite.
Clean up linked libraries for android. Clean up linked libraries for android.
JavaScript debugger improved and bugfixed. JavaScript debugger improved and bugfixed.
Fix flags for debugger server socket.
Nicolas Gramlich (nicolasgramlich, Zynga) Nicolas Gramlich (nicolasgramlich, Zynga)
fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF

View File

@ -1,3 +1,8 @@
cocos2d-x-3.0alpha0-pre @Jul.24 2013
[all platforms]
Feature #XXXX: Add support for std::function<> in CCMemuItem and CCCallFunc
cocos2d-2.1rc0-x-2.1.3 @May.01 2013 cocos2d-2.1rc0-x-2.1.3 @May.01 2013
[all platforms] [all platforms]
Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project

View File

@ -289,7 +289,8 @@ bool initAudioPlayer(AudioPlayer* player, const char* filename)
if(fp){ if(fp){
SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename}; SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
(player->audioSrc) = {&loc_fd, &format_mime}; player->audioSrc.pLocator = &loc_fd;
player->audioSrc.pFormat = &format_mime;
return createAudioPlayerBySource(player); return createAudioPlayerBySource(player);
} }
LOGD("file not found! Stop preload file: %s", filename); LOGD("file not found! Stop preload file: %s", filename);

View File

@ -24,12 +24,12 @@
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1067387441" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1067387441" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/cocosdenshion/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1261707379" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/> <builder autoBuildTarget="all" buildPath="${workspace_loc:/cocosdenshion/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1261707379" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
<tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/> <tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -49,7 +49,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -57,14 +56,15 @@
<listOptionValue builtIn="false" value="_DEBUG"/> <listOptionValue builtIn="false" value="_DEBUG"/>
<listOptionValue builtIn="false" value="TIZEN"/> <listOptionValue builtIn="false" value="TIZEN"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.174888158" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/> <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
</tool> </tool>
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler"> <tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> <option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -79,7 +79,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -89,12 +88,11 @@
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/> <inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
</tool> </tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
</tool> </tool>

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include <string> #include <string>
#include <functional> #include <functional>
#include "CCStdC.h"
#include "ccTypeInfo.h" #include "ccTypeInfo.h"
#include "CCAction.h" #include "CCAction.h"
@ -213,7 +214,7 @@ public:
: m_pSelectorTarget(NULL) : m_pSelectorTarget(NULL)
, m_nScriptHandler(0) , m_nScriptHandler(0)
, m_pCallFunc(NULL) , m_pCallFunc(NULL)
, _function(NULL) , _function(nullptr)
{ {
} }
virtual ~CCCallFunc(); virtual ~CCCallFunc();

View File

@ -7,7 +7,7 @@
NS_CC_BEGIN NS_CC_BEGIN
class CCData : public CCObject class CC_DLL CCData : public CCObject
{ {
public: public:
CCData(unsigned char *pBytes, const unsigned long nSize); CCData(unsigned char *pBytes, const unsigned long nSize);

View File

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

View File

@ -96,6 +96,18 @@ CCLabelTTF* CCLabelTTF::create(const char *string, const char *fontName, float f
return NULL; return NULL;
} }
CCLabelTTF * CCLabelTTF::createWithFontDefinition(const char *string, ccFontDefinition &textDefinition)
{
CCLabelTTF *pRet = new CCLabelTTF();
if(pRet && pRet->initWithStringAndTextDefinition(string, textDefinition))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
bool CCLabelTTF::init() bool CCLabelTTF::init()
{ {
return this->initWithString("", "Helvetica", 12); return this->initWithString("", "Helvetica", 12);

View File

@ -70,6 +70,10 @@ public:
const CCSize& dimensions, CCTextAlignment hAlignment, const CCSize& dimensions, CCTextAlignment hAlignment,
CCVerticalTextAlignment vAlignment); CCVerticalTextAlignment vAlignment);
/** Create a lable with string and a font definition*/
static CCLabelTTF * createWithFontDefinition(const char *string, ccFontDefinition &textDefinition);
/** initializes the CCLabelTTF with a font name and font size */ /** initializes the CCLabelTTF with a font name and font size */
bool initWithString(const char *string, const char *fontName, float fontSize); bool initWithString(const char *string, const char *fontName, float fontSize);

View File

@ -52,7 +52,7 @@ const unsigned int kDisableTag = 0x3;
CCMenuItem* CCMenuItem::create() CCMenuItem* CCMenuItem::create()
{ {
return CCMenuItem::create((const ccMenuCallback&)NULL); return CCMenuItem::create((const ccMenuCallback&)nullptr);
} }
// XXX deprecated // XXX deprecated
@ -161,6 +161,7 @@ bool CCMenuItem::isSelected()
return m_bSelected; return m_bSelected;
} }
// XXX deprecated
void CCMenuItem::setTarget(CCObject *target, SEL_MenuHandler selector) void CCMenuItem::setTarget(CCObject *target, SEL_MenuHandler selector)
{ {
_target = target; _target = target;
@ -227,7 +228,7 @@ CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, const ccMenuCallback& ca
CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label) CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label)
{ {
CCMenuItemLabel *pRet = new CCMenuItemLabel(); CCMenuItemLabel *pRet = new CCMenuItemLabel();
pRet->initWithLabel(label, (const ccMenuCallback&) NULL); pRet->initWithLabel(label, (const ccMenuCallback&) nullptr);
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
} }
@ -334,7 +335,7 @@ void CCMenuItemLabel::setEnabled(bool enabled)
CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
{ {
return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)NULL); return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)nullptr);
} }
// XXX: deprecated // XXX: deprecated
@ -427,11 +428,12 @@ CCMenuItemFont * CCMenuItemFont::create(const char *value, const ccMenuCallback&
CCMenuItemFont * CCMenuItemFont::create(const char *value) CCMenuItemFont * CCMenuItemFont::create(const char *value)
{ {
CCMenuItemFont *pRet = new CCMenuItemFont(); CCMenuItemFont *pRet = new CCMenuItemFont();
pRet->initWithString(value, (const ccMenuCallback&)NULL); pRet->initWithString(value, (const ccMenuCallback&)nullptr);
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
} }
// XXX: deprecated
bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_MenuHandler selector) bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_MenuHandler selector)
{ {
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
@ -571,7 +573,7 @@ void CCMenuItemSprite::setDisabledImage(CCNode* pImage)
CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite)
{ {
return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)NULL); return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)nullptr);
} }
// XXX deprecated // XXX deprecated
@ -726,12 +728,12 @@ CCMenuItemImage* CCMenuItemImage::create()
bool CCMenuItemImage::init(void) bool CCMenuItemImage::init(void)
{ {
return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)NULL); return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)nullptr);
} }
CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage) CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage)
{ {
return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)NULL); return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)nullptr);
} }
// XXX deprecated // XXX deprecated
@ -773,7 +775,7 @@ CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *s
CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage) CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage)
{ {
CCMenuItemImage *pRet = new CCMenuItemImage(); CCMenuItemImage *pRet = new CCMenuItemImage();
if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)NULL)) if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)nullptr))
{ {
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
@ -846,6 +848,7 @@ CCArray* CCMenuItemToggle::getSubItems()
return m_pSubItems; return m_pSubItems;
} }
// XXX: deprecated
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems) CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems)
{ {
CCMenuItemToggle *pRet = new CCMenuItemToggle(); CCMenuItemToggle *pRet = new CCMenuItemToggle();
@ -864,6 +867,25 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu
return pRet; return pRet;
} }
CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCArray* menuItems)
{
CCMenuItemToggle *pRet = new CCMenuItemToggle();
pRet->CCMenuItem::initWithCallback(callback);
pRet->m_pSubItems = CCArray::create();
pRet->m_pSubItems->retain();
for (unsigned int z=0; z < menuItems->count(); z++)
{
CCMenuItem* menuItem = (CCMenuItem*)menuItems->objectAtIndex(z);
pRet->m_pSubItems->addObject(menuItem);
}
pRet->m_uSelectedIndex = UINT_MAX;
pRet->setSelectedIndex(0);
return pRet;
}
// XXX: deprecated
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
{ {
va_list args; va_list args;
@ -875,6 +897,17 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu
return pRet; return pRet;
} }
CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCMenuItem* item, ...)
{
va_list args;
va_start(args, item);
CCMenuItemToggle *pRet = new CCMenuItemToggle();
pRet->initWithCallback(callback, item, args);
pRet->autorelease();
va_end(args);
return pRet;
}
CCMenuItemToggle * CCMenuItemToggle::create() CCMenuItemToggle * CCMenuItemToggle::create()
{ {
CCMenuItemToggle *pRet = new CCMenuItemToggle(); CCMenuItemToggle *pRet = new CCMenuItemToggle();
@ -883,9 +916,17 @@ CCMenuItemToggle * CCMenuItemToggle::create()
return pRet; return pRet;
} }
// XXX: deprecated
bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args) bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args)
{ {
CCMenuItem::initWithTarget(target, selector); _target = target;
CC_SAFE_RETAIN(_target);
return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args);
}
bool CCMenuItemToggle::initWithCallback(const ccMenuCallback &callback, CCMenuItem *item, va_list args)
{
CCMenuItem::initWithCallback(callback);
this->m_pSubItems = CCArray::create(); this->m_pSubItems = CCArray::create();
this->m_pSubItems->retain(); this->m_pSubItems->retain();
int z = 0; int z = 0;
@ -911,7 +952,7 @@ CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item)
bool CCMenuItemToggle::initWithItem(CCMenuItem *item) bool CCMenuItemToggle::initWithItem(CCMenuItem *item)
{ {
CCMenuItem::initWithCallback((const ccMenuCallback&)NULL); CCMenuItem::initWithCallback((const ccMenuCallback&)nullptr);
setSubItems(CCArray::create()); setSubItems(CCArray::create());
if (item) if (item)

View File

@ -71,7 +71,7 @@ public:
, m_bEnabled(false) , m_bEnabled(false)
, m_nScriptTapHandler(0) , m_nScriptTapHandler(0)
, _target(NULL) , _target(NULL)
, _callback(NULL) , _callback(nullptr)
{} {}
virtual ~CCMenuItem(); virtual ~CCMenuItem();
@ -374,12 +374,12 @@ public:
/** creates a menu item from a CCArray with a target selector */ /** creates a menu item from a CCArray with a target selector */
CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle * createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems); CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle * createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems);
/** creates a menu item from a CCArray with a callable object */ /** creates a menu item from a CCArray with a callable object */
static CCMenuItemToggle * createWithTarget(const ccMenuCallback& callback, CCArray* menuItems); static CCMenuItemToggle * createWithCallback(const ccMenuCallback& callback, CCArray* menuItems);
/** creates a menu item from a list of items with a target/selector */ /** creates a menu item from a list of items with a target/selector */
CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
/** creates a menu item from a list of items with a callable object */ /** creates a menu item from a list of items with a callable object */
static CCMenuItemToggle* createWithTarget(const ccMenuCallback& callback, CCMenuItem* item, ...); static CCMenuItemToggle* createWithCallback(const ccMenuCallback& callback, CCMenuItem* item, ...);
/** creates a menu item with no target/selector and no items */ /** creates a menu item with no target/selector and no items */
static CCMenuItemToggle* create(); static CCMenuItemToggle* create();
@ -387,7 +387,7 @@ public:
/** initializes a menu item from a list of items with a target selector */ /** initializes a menu item from a list of items with a target selector */
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args); CC_DEPRECATED_ATTRIBUTE bool initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args);
/** initializes a menu item from a list of items with a callable object */ /** initializes a menu item from a list of items with a callable object */
bool initWithTarget(const ccMenuCallback& callback, CCMenuItem* item, va_list args); bool initWithCallback(const ccMenuCallback& callback, CCMenuItem* item, va_list args);
/** creates a menu item with a item */ /** creates a menu item with a item */
static CCMenuItemToggle* create(CCMenuItem *item); static CCMenuItemToggle* create(CCMenuItem *item);

View File

@ -166,7 +166,7 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h
bool CCEGLViewProtocol::isScissorEnabled() bool CCEGLViewProtocol::isScissorEnabled()
{ {
return glIsEnabled(GL_SCISSOR_TEST); return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true;
} }
CCRect CCEGLViewProtocol::getScissorRect() CCRect CCEGLViewProtocol::getScissorRect()

View File

@ -118,10 +118,11 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch
return 0; return 0;
} }
if (pszFileName[0] != '/') string fullPath = fullPathForFilename(pszFileName);
if (fullPath[0] != '/')
{ {
//CCLOG("GETTING FILE RELATIVE DATA: %s", pszFileName); //CCLOG("GETTING FILE RELATIVE DATA: %s", pszFileName);
string fullPath = fullPathForFilename(pszFileName);
pData = s_pZipFile->getFileData(fullPath.c_str(), pSize); pData = s_pZipFile->getFileData(fullPath.c_str(), pSize);
} }
else else
@ -130,7 +131,7 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch
{ {
// read rrom other path than user set it // read rrom other path than user set it
//CCLOG("GETTING FILE ABSOLUTE DATA: %s", pszFileName); //CCLOG("GETTING FILE ABSOLUTE DATA: %s", pszFileName);
FILE *fp = fopen(pszFileName, pszMode); FILE *fp = fopen(fullPath.c_str(), pszMode);
CC_BREAK_IF(!fp); CC_BREAK_IF(!fp);
unsigned long size; unsigned long size;

View File

@ -12,4 +12,4 @@
android.library=true android.library=true
# Project target. # Project target.
target=android-17 target=android-8

View File

@ -65,7 +65,6 @@ public class Cocos2dxETCLoader {
texture = ETC1Util.createTexture(inputStream); texture = ETC1Util.createTexture(inputStream);
inputStream.close(); inputStream.close();
assetManager.close();
} catch (Exception e) { } catch (Exception e) {
Log.d("Cocos2dx", "Unable to create texture for " + filePath); Log.d("Cocos2dx", "Unable to create texture for " + filePath);
@ -73,24 +72,29 @@ public class Cocos2dxETCLoader {
} }
if (texture != null) { if (texture != null) {
try { boolean ret = true;
int width = texture.getWidth();
int height = texture.getHeight();
final byte[] data = new byte[width * height * 3]; try {
final int width = texture.getWidth();
final int height = texture.getHeight();
final int length = texture.getData().remaining();
final byte[] data = new byte[length];
final ByteBuffer buf = ByteBuffer.wrap(data); final ByteBuffer buf = ByteBuffer.wrap(data);
buf.order(ByteOrder.nativeOrder()); buf.order(ByteOrder.nativeOrder());
buf.put(texture.getData()); buf.put(texture.getData());
nativeSetTextureInfo(width, nativeSetTextureInfo(width,
height, height,
data); data,
length);
} catch (Exception e) } catch (Exception e)
{ {
Log.d("invoke native function error", e.toString()); Log.d("invoke native function error", e.toString());
ret = false;
} }
return true; return ret;
} else { } else {
return false; return false;
} }
@ -100,5 +104,6 @@ public class Cocos2dxETCLoader {
Cocos2dxETCLoader.context = context; Cocos2dxETCLoader.context = context;
} }
private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data); private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data,
final int dataLength);
} }

View File

@ -29,8 +29,6 @@ THE SOFTWARE.
#include <FGraphicsOpengl2.h> #include <FGraphicsOpengl2.h>
using namespace Tizen::Graphics::Opengl; using namespace Tizen::Graphics::Opengl;
typedef char GLchar;
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define glClearDepth glClearDepthf #define glClearDepth glClearDepthf

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdarg.h>
#include <float.h> #include <float.h>
#ifndef MIN #ifndef MIN
@ -40,4 +41,6 @@ THE SOFTWARE.
#define MAX(x,y) (((x) < (y)) ? (y) : (x)) #define MAX(x,y) (((x) < (y)) ? (y) : (x))
#endif // MAX #endif // MAX
#define nullptr __null
#endif // __CC_STD_C_H__ #endif // __CC_STD_C_H__

View File

@ -1 +1 @@
0b4fa0b87348ffa5b356628b5dd4907d0f8e7b86 4f421e1ed8425f53876db5971e3deac238edb4d3

View File

@ -30,12 +30,12 @@
</outputEntries> </outputEntries>
</builder> </builder>
<tool command="i386-linux-gnueabi-ar.exe" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/> <tool command="i386-linux-gnueabi-ar.exe" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -57,7 +57,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -65,14 +64,15 @@
<listOptionValue builtIn="false" value="_DEBUG"/> <listOptionValue builtIn="false" value="_DEBUG"/>
<listOptionValue builtIn="false" value="TIZEN"/> <listOptionValue builtIn="false" value="TIZEN"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.857204721" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/> <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
</tool> </tool>
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler"> <tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> <option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -91,7 +91,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -102,12 +101,11 @@
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/> <inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
</tool> </tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
</tool> </tool>

View File

@ -554,18 +554,14 @@ void CCSprite::draw(void)
if (m_pobTexture != NULL) if (m_pobTexture != NULL)
{ {
ccGLBindTexture2D( m_pobTexture->getName() ); ccGLBindTexture2D( m_pobTexture->getName() );
ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
} }
else else
{ {
ccGLBindTexture2D(0); ccGLBindTexture2D(0);
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );
} }
//
// Attributes
//
ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
#define kQuadSize sizeof(m_sQuad.bl) #define kQuadSize sizeof(m_sQuad.bl)
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
long offset = 0; long offset = 0;
@ -578,9 +574,12 @@ void CCSprite::draw(void)
int diff = offsetof( ccV3F_C4B_T2F, vertices); int diff = offsetof( ccV3F_C4B_T2F, vertices);
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods if (m_pobTexture != NULL)
diff = offsetof( ccV3F_C4B_T2F, texCoords); {
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // texCoods
diff = offsetof( ccV3F_C4B_T2F, texCoords);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
}
// color // color
diff = offsetof( ccV3F_C4B_T2F, colors); diff = offsetof( ccV3F_C4B_T2F, colors);

View File

@ -232,6 +232,7 @@ CCDictionary* CCTextureCache::snapshotTextures()
{ {
pRet->setObject(pElement->getObject(), pElement->getStrKey()); pRet->setObject(pElement->getObject(), pElement->getStrKey());
} }
pRet->autorelease();
return pRet; return pRet;
} }

View File

@ -81,11 +81,11 @@ static unsigned int sLength = 0;
extern "C" extern "C"
{ {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data) JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data, jint dataLength)
{ {
sWidth = (unsigned int)width; sWidth = (unsigned int)width;
sHeight = (unsigned int)height; sHeight = (unsigned int)height;
sLength = sWidth * sHeight * 3; sLength = dataLength;
sData = new unsigned char[sLength]; sData = new unsigned char[sLength];
env->GetByteArrayRegion(data, 0, sLength, (jbyte*)sData); env->GetByteArrayRegion(data, 0, sLength, (jbyte*)sData);
} }

View File

@ -621,7 +621,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
// Read properties // Read properties
ccNodeLoader->parseProperties(node, pParent, this); ccNodeLoader->parseProperties(node, pParent, this);
bool isCCBFileNode = dynamic_cast<CCBFile*>(node); bool isCCBFileNode = (NULL == dynamic_cast<CCBFile*>(node)) ? false : true;
// Handle sub ccb files (remove middle node) // Handle sub ccb files (remove middle node)
if (isCCBFileNode) if (isCCBFileNode)
{ {

View File

@ -46,24 +46,9 @@ CCControlColourPicker::CCControlColourPicker()
CCControlColourPicker::~CCControlColourPicker() CCControlColourPicker::~CCControlColourPicker()
{ {
if (m_background) CC_SAFE_RELEASE(m_background);
{ CC_SAFE_RELEASE(m_huePicker);
m_background->removeFromParentAndCleanup(true); CC_SAFE_RELEASE(m_colourPicker);
}
if (m_huePicker)
{
m_huePicker->removeFromParentAndCleanup(true);
}
if (m_colourPicker)
{
m_colourPicker->removeFromParentAndCleanup(true);
}
m_background = NULL;
m_huePicker = NULL;
m_colourPicker = NULL;
} }
bool CCControlColourPicker::init() bool CCControlColourPicker::init()
@ -94,6 +79,7 @@ bool CCControlColourPicker::init()
// Add image // Add image
m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPointZero, ccp(0.5f, 0.5f)); m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPointZero, ccp(0.5f, 0.5f));
CC_SAFE_RETAIN(m_background);
CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2)); CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2));

View File

@ -557,6 +557,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
CC_SAFE_DELETE(data); CC_SAFE_DELETE(data);
CC_SAFE_DELETE_ARRAY(buf); CC_SAFE_DELETE_ARRAY(buf);
} }
CC_SAFE_DELETE(subThreadMsg);
} }
_wsHelper->_subThreadWsMessageQueue->clear(); _wsHelper->_subThreadWsMessageQueue->clear();

View File

@ -30,18 +30,19 @@
</outputEntries> </outputEntries>
</builder> </builder>
<tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/> <tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler"> <tool command="i386-linux-gnueabi-g++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/extensions&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/extensions&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/CocosDenshion/include&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/CocosDenshion/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/external/chipmunk/include/chipmunk&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/external/chipmunk/include/chipmunk&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/external/libwebsockets/tizen/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/external&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/external&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_SRC}&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_SRC}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/include&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/include&quot;"/>
@ -59,7 +60,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -69,14 +69,15 @@
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/> <listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
<listOptionValue builtIn="false" value="CC_ENABLE_BOX2D_INTEGRATION=0"/> <listOptionValue builtIn="false" value="CC_ENABLE_BOX2D_INTEGRATION=0"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.1649119739" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/> <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
</tool> </tool>
<tool command="clang.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler"> <tool command="i386-linux-gnueabi-gcc.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> <option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -95,7 +96,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIC"/> <listOptionValue builtIn="false" value=" -fPIC"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -108,12 +108,11 @@
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/> <inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
</tool> </tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
</tool> </tool>

View File

@ -0,0 +1,977 @@
/*
* libwebsockets - small server side websockets and web server implementation
*
* Copyright (C) 2010-2013 Andy Green <andy@warmcat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation:
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#ifndef __LIBWEBSOCKET_H__
#define __LIBWEBSOCKET_H__
#ifdef __cplusplus
extern "C" {
#include <cstddef>
#endif
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stddef.h>
#include "../win32port/win32helpers/websock-w32.h"
#include "../win32port/win32helpers/gettimeofday.h"
#define strcasecmp stricmp
#define getdtablesize() 30000
typedef int ssize_t;
#ifdef LWS_DLL
#ifdef LWS_INTERNAL
#define LWS_EXTERN extern __declspec(dllexport)
#else
#define LWS_EXTERN extern __declspec(dllimport)
#endif
#endif
#else // NOT WIN32
#include <poll.h>
#include <unistd.h>
#endif
#include <assert.h>
#ifndef LWS_EXTERN
#define LWS_EXTERN extern
#endif
#define CONTEXT_PORT_NO_LISTEN 0
#define MAX_MUX_RECURSION 2
enum lws_log_levels {
LLL_ERR = 1 << 0,
LLL_WARN = 1 << 1,
LLL_NOTICE = 1 << 2,
LLL_INFO = 1 << 3,
LLL_DEBUG = 1 << 4,
LLL_PARSER = 1 << 5,
LLL_HEADER = 1 << 6,
LLL_EXT = 1 << 7,
LLL_CLIENT = 1 << 8,
LLL_LATENCY = 1 << 9,
LLL_COUNT = 10 /* set to count of valid flags */
};
LWS_EXTERN void _lws_log(int filter, const char *format, ...);
/* notice, warn and log are always compiled in */
#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)
#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)
#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
/*
* weaker logging can be deselected at configure time using --disable-debug
* that gets rid of the overhead of checking while keeping _warn and _err
* active
*/
#ifdef _DEBUG
#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__)
#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__)
#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__)
#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__)
#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__)
#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)
#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)
LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
#else /* no debug */
#define lwsl_info(...)
#define lwsl_debug(...)
#define lwsl_parser(...)
#define lwsl_header(...)
#define lwsl_ext(...)
#define lwsl_client(...)
#define lwsl_latency(...)
#define lwsl_hexdump(a, b)
#endif
enum libwebsocket_context_options {
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4,
};
enum libwebsocket_callback_reasons {
LWS_CALLBACK_ESTABLISHED,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
LWS_CALLBACK_CLIENT_ESTABLISHED,
LWS_CALLBACK_CLOSED,
LWS_CALLBACK_RECEIVE,
LWS_CALLBACK_CLIENT_RECEIVE,
LWS_CALLBACK_CLIENT_RECEIVE_PONG,
LWS_CALLBACK_CLIENT_WRITEABLE,
LWS_CALLBACK_SERVER_WRITEABLE,
LWS_CALLBACK_HTTP,
LWS_CALLBACK_HTTP_FILE_COMPLETION,
LWS_CALLBACK_HTTP_WRITEABLE,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION,
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED,
LWS_CALLBACK_PROTOCOL_INIT,
LWS_CALLBACK_PROTOCOL_DESTROY,
/* external poll() management support */
LWS_CALLBACK_ADD_POLL_FD,
LWS_CALLBACK_DEL_POLL_FD,
LWS_CALLBACK_SET_MODE_POLL_FD,
LWS_CALLBACK_CLEAR_MODE_POLL_FD,
};
#ifndef LWS_NO_EXTENSIONS
enum libwebsocket_extension_callback_reasons {
LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT,
LWS_EXT_CALLBACK_CONSTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE,
LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION,
LWS_EXT_CALLBACK_DESTROY,
LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING,
LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED,
LWS_EXT_CALLBACK_PACKET_RX_PREPARSE,
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
LWS_EXT_CALLBACK_PACKET_TX_DO_SEND,
LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX,
LWS_EXT_CALLBACK_FLUSH_PENDING_TX,
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
LWS_EXT_CALLBACK_1HZ,
LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE,
LWS_EXT_CALLBACK_IS_WRITEABLE,
LWS_EXT_CALLBACK_PAYLOAD_TX,
LWS_EXT_CALLBACK_PAYLOAD_RX,
};
#endif
enum libwebsocket_write_protocol {
LWS_WRITE_TEXT,
LWS_WRITE_BINARY,
LWS_WRITE_CONTINUATION,
LWS_WRITE_HTTP,
/* special 04+ opcodes */
LWS_WRITE_CLOSE,
LWS_WRITE_PING,
LWS_WRITE_PONG,
/* flags */
LWS_WRITE_NO_FIN = 0x40,
/*
* client packet payload goes out on wire unmunged
* only useful for security tests since normal servers cannot
* decode the content if used
*/
LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80
};
/*
* you need these to look at headers that have been parsed if using the
* LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum
* list below is absent, .token = NULL and token_len = 0. Otherwise .token
* points to .token_len chars containing that header content.
*/
struct lws_tokens {
char *token;
int token_len;
};
enum lws_token_indexes {
WSI_TOKEN_GET_URI,
WSI_TOKEN_HOST,
WSI_TOKEN_CONNECTION,
WSI_TOKEN_KEY1,
WSI_TOKEN_KEY2,
WSI_TOKEN_PROTOCOL,
WSI_TOKEN_UPGRADE,
WSI_TOKEN_ORIGIN,
WSI_TOKEN_DRAFT,
WSI_TOKEN_CHALLENGE,
/* new for 04 */
WSI_TOKEN_KEY,
WSI_TOKEN_VERSION,
WSI_TOKEN_SWORIGIN,
/* new for 05 */
WSI_TOKEN_EXTENSIONS,
/* client receives these */
WSI_TOKEN_ACCEPT,
WSI_TOKEN_NONCE,
WSI_TOKEN_HTTP,
WSI_TOKEN_MUXURL,
/* use token storage to stash these */
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS,
_WSI_TOKEN_CLIENT_PEER_ADDRESS,
_WSI_TOKEN_CLIENT_URI,
_WSI_TOKEN_CLIENT_HOST,
_WSI_TOKEN_CLIENT_ORIGIN,
/* always last real token index*/
WSI_TOKEN_COUNT,
/* parser state additions */
WSI_TOKEN_NAME_PART,
WSI_TOKEN_SKIPPING,
WSI_TOKEN_SKIPPING_SAW_CR,
WSI_PARSING_COMPLETE,
WSI_INIT_TOKEN_MUXURL,
};
/*
* From RFC 6455
1000
1000 indicates a normal closure, meaning that the purpose for
which the connection was established has been fulfilled.
1001
1001 indicates that an endpoint is "going away", such as a server
going down or a browser having navigated away from a page.
1002
1002 indicates that an endpoint is terminating the connection due
to a protocol error.
1003
1003 indicates that an endpoint is terminating the connection
because it has received a type of data it cannot accept (e.g., an
endpoint that understands only text data MAY send this if it
receives a binary message).
1004
Reserved. The specific meaning might be defined in the future.
1005
1005 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that no status
code was actually present.
1006
1006 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that the
connection was closed abnormally, e.g., without sending or
receiving a Close control frame.
1007
1007 indicates that an endpoint is terminating the connection
because it has received data within a message that was not
consistent with the type of the message (e.g., non-UTF-8 [RFC3629]
data within a text message).
1008
1008 indicates that an endpoint is terminating the connection
because it has received a message that violates its policy. This
is a generic status code that can be returned when there is no
other more suitable status code (e.g., 1003 or 1009) or if there
is a need to hide specific details about the policy.
1009
1009 indicates that an endpoint is terminating the connection
because it has received a message that is too big for it to
process.
1010
1010 indicates that an endpoint (client) is terminating the
connection because it has expected the server to negotiate one or
more extension, but the server didn't return them in the response
message of the WebSocket handshake. The list of extensions that
are needed SHOULD appear in the /reason/ part of the Close frame.
Note that this status code is not used by the server, because it
can fail the WebSocket handshake instead.
1011
1011 indicates that a server is terminating the connection because
it encountered an unexpected condition that prevented it from
fulfilling the request.
1015
1015 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that the
connection was closed due to a failure to perform a TLS handshake
(e.g., the server certificate can't be verified).
*/
enum lws_close_status {
LWS_CLOSE_STATUS_NOSTATUS = 0,
LWS_CLOSE_STATUS_NORMAL = 1000,
LWS_CLOSE_STATUS_GOINGAWAY = 1001,
LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002,
LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003,
LWS_CLOSE_STATUS_RESERVED = 1004,
LWS_CLOSE_STATUS_NO_STATUS = 1005,
LWS_CLOSE_STATUS_ABNORMAL_CLOSE = 1006,
LWS_CLOSE_STATUS_INVALID_PAYLOAD = 1007,
LWS_CLOSE_STATUS_POLICY_VIOLATION = 1008,
LWS_CLOSE_STATUS_MESSAGE_TOO_LARGE = 1009,
LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010,
LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011,
LWS_CLOSE_STATUS_TLS_FAILURE = 1015,
};
struct libwebsocket;
struct libwebsocket_context;
/* needed even with extensions disabled for create context */
struct libwebsocket_extension;
/**
* callback_function() - User server actions
* @context: Websockets context
* @wsi: Opaque websocket instance pointer
* @reason: The reason for the call
* @user: Pointer to per-session user data allocated by library
* @in: Pointer used for some callback reasons
* @len: Length set for some callback reasons
*
* This callback is the way the user controls what is served. All the
* protocol detail is hidden and handled by the library.
*
* For each connection / session there is user data allocated that is
* pointed to by "user". You set the size of this user data area when
* the library is initialized with libwebsocket_create_server.
*
* You get an opportunity to initialize user data when called back with
* LWS_CALLBACK_ESTABLISHED reason.
*
* LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with
* an incoming client
*
* LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has
* been unable to complete a handshake with the remote server
*
* LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH: this is the last chance for the
* client user code to examine the http headers
* and decide to reject the connection. If the
* content in the headers is interesting to the
* client (url, etc) it needs to copy it out at
* this point since it will be destroyed before
* the CLIENT_ESTABLISHED call
*
* LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed
* a handshake with the remote server
*
* LWS_CALLBACK_CLOSED: when the websocket session ends
*
* LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a
* remote client, it can be found at *in and is
* len bytes long
*
* LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets,
* they appear with this callback reason. PONG
* packets only exist in 04+ protocol
*
* LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the
* client connection, it can be found at *in and
* is len bytes long
*
* LWS_CALLBACK_HTTP: an http request has come from a client that is not
* asking to upgrade the connection to a websocket
* one. This is a chance to serve http content,
* for example, to send a script to the client
* which will then open the websockets connection.
* @in points to the URI path requested and
* libwebsockets_serve_http_file() makes it very
* simple to send back a file to the client.
* Normally after sending the file you are done
* with the http connection, since the rest of the
* activity will come by websockets from the script
* that was delivered by http, so you will want to
* return 1; to close and free up the connection.
* That's important because it uses a slot in the
* total number of client connections allowed set
* by MAX_CLIENTS.
*
* LWS_CALLBACK_HTTP_WRITEABLE: you can write more down the http protocol
* link now.
*
* LWS_CALLBACK_HTTP_FILE_COMPLETION: a file requested to be send down
* http link has completed.
*
* LWS_CALLBACK_CLIENT_WRITEABLE:
* LWS_CALLBACK_SERVER_WRITEABLE: If you call
* libwebsocket_callback_on_writable() on a connection, you will
* get one of these callbacks coming when the connection socket
* is able to accept another write packet without blocking.
* If it already was able to take another packet without blocking,
* you'll get this callback at the next call to the service loop
* function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
* and servers get LWS_CALLBACK_SERVER_WRITEABLE.
*
* LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to
* the server at network level; the connection is accepted but then
* passed to this callback to decide whether to hang up immediately
* or not, based on the client IP. @in contains the connection
* socket's descriptor. Return non-zero to terminate
* the connection before sending or receiving anything.
* Because this happens immediately after the network connection
* from the client, there's no websocket protocol selected yet so
* this callback is issued only to protocol 0.
*
* LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has
* been received and parsed from the client, but the response is
* not sent yet. Return non-zero to disallow the connection.
* @user is a pointer to an array of struct lws_tokens, you can
* use the header enums lws_token_indexes from libwebsockets.h
* to check for and read the supported header presence and
* content before deciding to allow the handshake to proceed or
* to kill the connection.
*
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for
* including OpenSSL support, this callback allows your user code
* to perform extra SSL_CTX_load_verify_locations() or similar
* calls to direct OpenSSL where to find certificates the client
* can use to confirm the remote server identity. @user is the
* OpenSSL SSL_CTX*
*
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for
* including OpenSSL support, this callback allows your user code
* to load extra certifcates into the server which allow it to
* verify the validity of certificates returned by clients. @user
* is the server's OpenSSL SSL_CTX*
*
* LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the
* libwebsockets context was created with the option
* LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this
* callback is generated during OpenSSL verification of the cert
* sent from the client. It is sent to protocol[0] callback as
* no protocol has been negotiated on the connection yet.
* Notice that the libwebsockets context and wsi are both NULL
* during this callback. See
* http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
* to understand more detail about the OpenSSL callback that
* generates this libwebsockets callback and the meanings of the
* arguments passed. In this callback, @user is the x509_ctx,
* @in is the ssl pointer and @len is preverify_ok
* Notice that this callback maintains libwebsocket return
* conventions, return 0 to mean the cert is OK or 1 to fail it.
* This also means that if you don't handle this callback then
* the default callback action of returning 0 allows the client
* certificates.
*
* LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens
* when a client handshake is being compiled. @user is NULL,
* @in is a char **, it's pointing to a char * which holds the
* next location in the header buffer where you can add
* headers, and @len is the remaining space in the header buffer,
* which is typically some hundreds of bytes. So, to add a canned
* cookie, your handler code might look similar to:
*
* char **p = (char **)in;
*
* if (len < 100)
* return 1;
*
* *p += sprintf(*p, "Cookie: a=b\x0d\x0a");
*
* return 0;
*
* Notice if you add anything, you just have to take care about
* the CRLF on the line you added. Obviously this callback is
* optional, if you don't handle it everything is fine.
*
* Notice the callback is coming to protocols[0] all the time,
* because there is no specific protocol handshook yet.
*
* LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code
* sees that it does support a requested extension, before
* accepting the extension by additing to the list sent back to
* the client it gives this callback just to check that it's okay
* to use that extension. It calls back to the requested protocol
* and with @in being the extension name, @len is 0 and @user is
* valid. Note though at this time the ESTABLISHED callback hasn't
* happened yet so if you initialize @user content there, @user
* content during this callback might not be useful for anything.
* Notice this callback comes to protocols[0].
*
* LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client
* connection is being prepared to start a handshake to a server,
* each supported extension is checked with protocols[0] callback
* with this reason, giving the user code a chance to suppress the
* claim to support that extension by returning non-zero. If
* unhandled, by default 0 will be returned and the extension
* support included in the header to the server. Notice this
* callback comes to protocols[0].
*
* LWS_CALLBACK_PROTOCOL_INIT: One-time call per protocol so it can
* do initial setup / allocations etc
*
* LWS_CALLBACK_PROTOCOL_DESTROY: One-time call per protocol indicating
* this protocol won't get used at all after this callback, the
* context is getting destroyed. Take the opportunity to
* deallocate everything that was allocated by the protocol.
*
* The next four reasons are optional and only need taking care of if you
* will be integrating libwebsockets sockets into an external polling
* array.
*
* LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop
* internally, but in the case you are integrating with another
* server you will need to have libwebsocket sockets share a
* polling array with the other server. This and the other
* POLL_FD related callbacks let you put your specialized
* poll array interface code in the callback for protocol 0, the
* first protocol you support, usually the HTTP protocol in the
* serving case. This callback happens when a socket needs to be
* added to the polling loop: @in contains the fd, and
* @len is the events bitmap (like, POLLIN). If you are using the
* internal polling loop (the "service" callback), you can just
* ignore these callbacks.
*
* LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
* needs to be removed from an external polling array. @in is
* the socket desricptor. If you are using the internal polling
* loop, you can just ignore it.
*
* LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets
* wants to modify the events for the socket descriptor in @in.
* The handler should OR @len on to the events member of the pollfd
* struct for this socket descriptor. If you are using the
* internal polling loop, you can just ignore it.
*
* LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets
* wants to modify the events for the socket descriptor in @in.
* The handler should AND ~@len on to the events member of the
* pollfd struct for this socket descriptor. If you are using the
* internal polling loop, you can just ignore it.
*/
LWS_EXTERN int callback(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
typedef int (callback_function)(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
#ifndef LWS_NO_EXTENSIONS
/**
* extension_callback_function() - Hooks to allow extensions to operate
* @context: Websockets context
* @ext: This extension
* @wsi: Opaque websocket instance pointer
* @reason: The reason for the call
* @user: Pointer to per-session user data allocated by library
* @in: Pointer used for some callback reasons
* @len: Length set for some callback reasons
*
* Each extension that is active on a particular connection receives
* callbacks during the connection lifetime to allow the extension to
* operate on websocket data and manage itself.
*
* Libwebsockets takes care of allocating and freeing "user" memory for
* each active extension on each connection. That is what is pointed to
* by the @user parameter.
*
* LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to
* select this extension from the list provided by the client,
* just before the server will send back the handshake accepting
* the connection with this extension active. This gives the
* extension a chance to initialize its connection context found
* in @user.
*
* LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT
* but called when client is instantiating this extension. Some
* extensions will work the same on client and server side and then
* you can just merge handlers for both CONSTRUCTS.
*
* LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was
* being used on is about to be closed and deallocated. It's the
* last chance for the extension to deallocate anything it has
* allocated in the user data (pointed to by @user) before the
* user data is deleted. This same callback is used whether you
* are in client or server instantiation context.
*
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on
* a connection, and a packet of data arrived at the connection,
* it is passed to this callback to give the extension a chance to
* change the data, eg, decompress it. @user is pointing to the
* extension's private connection context data, @in is pointing
* to an lws_tokens struct, it consists of a char * pointer called
* token, and an int called token_len. At entry, these are
* set to point to the received buffer and set to the content
* length. If the extension will grow the content, it should use
* a new buffer allocated in its private user context data and
* set the pointed-to lws_tokens members to point to its buffer.
*
* LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the
* extension a chance to change websocket data just before it will
* be sent out. Using the same lws_token pointer scheme in @in,
* the extension can change the buffer and the length to be
* transmitted how it likes. Again if it wants to grow the
* buffer safely, it should copy the data into its own buffer and
* set the lws_tokens token pointer to it.
*/
LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);
typedef int (extension_callback_function)(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);
#endif
/**
* struct libwebsocket_protocols - List of protocols and handlers server
* supports.
* @name: Protocol name that must match the one given in the client
* Javascript new WebSocket(url, 'protocol') name
* @callback: The service callback used for this protocol. It allows the
* service action for an entire protocol to be encapsulated in
* the protocol-specific callback
* @per_session_data_size: Each new connection using this protocol gets
* this much memory allocated on connection establishment and
* freed on connection takedown. A pointer to this per-connection
* allocation is passed into the callback in the 'user' parameter
* @rx_buffer_size: if you want atomic frames delivered to the callback, you
* should set this to the size of the biggest legal frame that
* you support. If the frame size is exceeded, there is no
* error, but the buffer will spill to the user callback when
* full, which you can detect by using
* libwebsockets_remaining_packet_payload(). Notice that you
* just talk about frame size here, the LWS_SEND_BUFFER_PRE_PADDING
* and post-padding are automatically also allocated on top.
* @owning_server: the server init call fills in this opaque pointer when
* registering this protocol with the server.
* @protocol_index: which protocol we are starting from zero
*
* This structure represents one protocol supported by the server. An
* array of these structures is passed to libwebsocket_create_server()
* allows as many protocols as you like to be handled by one server.
*/
struct libwebsocket_protocols {
const char *name;
callback_function *callback;
size_t per_session_data_size;
size_t rx_buffer_size;
/*
* below are filled in on server init and can be left uninitialized,
* no need for user to use them directly either
*/
struct libwebsocket_context *owning_server;
int protocol_index;
};
#ifndef LWS_NO_EXTENSIONS
/**
* struct libwebsocket_extension - An extension we know how to cope with
*
* @name: Formal extension name, eg, "deflate-stream"
* @callback: Service callback
* @per_session_data_size: Libwebsockets will auto-malloc this much
* memory for the use of the extension, a pointer
* to it comes in the @user callback parameter
* @per_context_private_data: Optional storage for this extension that
* is per-context, so it can track stuff across
* all sessions, etc, if it wants
*/
struct libwebsocket_extension {
const char *name;
extension_callback_function *callback;
size_t per_session_data_size;
void *per_context_private_data;
};
#endif
/**
* struct lws_context_creation_info: parameters to create context with
*
* @port: Port to listen on... you can use 0 to suppress listening on
* any port, that's what you want if you are not running a
* websocket server at all but just using it as a client
* @iface: NULL to bind the listen socket to all interfaces, or the
* interface name, eg, "eth2"
* @protocols: Array of structures listing supported protocols and a protocol-
* specific callback for each one. The list is ended with an
* entry that has a NULL callback pointer.
* It's not const because we write the owning_server member
* @extensions: NULL or array of libwebsocket_extension structs listing the
* extensions this context supports. If you configured with
* --without-extensions, you should give NULL here.
* @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want
* to listen using SSL, set to the filepath to fetch the
* server cert from, otherwise NULL for unencrypted
* @ssl_private_key_filepath: filepath to private key if wanting SSL mode,
* else ignored
* @ssl_ca_filepath: CA certificate filepath or NULL
* @ssl_cipher_list: List of valid ciphers to use (eg,
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL"
* or you can leave it as NULL to get "DEFAULT"
* @gid: group id to change to after setting listen socket, or -1.
* @uid: user id to change to after setting listen socket, or -1.
* @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
* @user: optional user pointer that can be recovered via the context
* pointer using libwebsocket_context_user
* @ka_time: 0 for no keepalive, otherwise apply this keepalive timeout to
* all libwebsocket sockets, client or server
* @ka_probes: if ka_time was nonzero, after the timeout expires how many
* times to try to get a response from the peer before giving up
* and killing the connection
* @ka_interval: if ka_time was nonzero, how long to wait before each ka_probes
* attempt
*/
struct lws_context_creation_info {
int port;
const char *iface;
struct libwebsocket_protocols *protocols;
struct libwebsocket_extension *extensions;
const char *ssl_cert_filepath;
const char *ssl_private_key_filepath;
const char *ssl_ca_filepath;
const char *ssl_cipher_list;
int gid;
int uid;
unsigned int options;
void *user;
int ka_time;
int ka_probes;
int ka_interval;
};
LWS_EXTERN
void lws_set_log_level(int level,
void (*log_emit_function)(int level, const char *line));
LWS_EXTERN void
lwsl_emit_syslog(int level, const char *line);
LWS_EXTERN struct libwebsocket_context *
libwebsocket_create_context(struct lws_context_creation_info *info);
LWS_EXTERN void
libwebsocket_context_destroy(struct libwebsocket_context *context);
LWS_EXTERN int
libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
LWS_EXTERN int
libwebsocket_service_fd(struct libwebsocket_context *context,
struct pollfd *pollfd);
LWS_EXTERN void *
libwebsocket_context_user(struct libwebsocket_context *context);
/*
* IMPORTANT NOTICE!
*
* When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY)
* the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE
* buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len).
*
* This allows us to add protocol info before and after the data, and send as
* one packet on the network without payload copying, for maximum efficiency.
*
* So for example you need this kind of code to use libwebsocket_write with a
* 128-byte payload
*
* char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING];
*
* // fill your part of the buffer... for example here it's all zeros
* memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
*
* libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128);
*
* When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
* use the whole buffer without taking care of the above.
*/
/*
* this is the frame nonce plus two header plus 8 length
* there's an additional two for mux extension per mux nesting level
* 2 byte prepend on close will already fit because control frames cannot use
* the big length style
*/
#define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION))
#define LWS_SEND_BUFFER_POST_PADDING 4
LWS_EXTERN int
libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
enum libwebsocket_write_protocol protocol);
LWS_EXTERN int
libwebsockets_serve_http_file(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
const char *content_type);
LWS_EXTERN int
libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_EXTERN const struct libwebsocket_protocols *
libwebsockets_get_protocol(struct libwebsocket *wsi);
LWS_EXTERN int
libwebsocket_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_EXTERN int
libwebsocket_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol);
LWS_EXTERN int
libwebsocket_get_socket_fd(struct libwebsocket *wsi);
LWS_EXTERN int
libwebsocket_is_final_fragment(struct libwebsocket *wsi);
LWS_EXTERN unsigned char
libwebsocket_get_reserved_bits(struct libwebsocket *wsi);
LWS_EXTERN int
libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
LWS_EXTERN size_t
libwebsockets_remaining_packet_payload(struct libwebsocket *wsi);
LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect(struct libwebsocket_context *clients,
const char *address,
int port,
int ssl_connection,
const char *path,
const char *host,
const char *origin,
const char *protocol,
int ietf_version_or_minus_one);
LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
const char *address,
int port,
int ssl_connection,
const char *path,
const char *host,
const char *origin,
const char *protocol,
int ietf_version_or_minus_one,
void *userdata);
LWS_EXTERN const char *
libwebsocket_canonical_hostname(struct libwebsocket_context *context);
LWS_EXTERN void
libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, int fd, char *name, int name_len,
char *rip, int rip_len);
LWS_EXTERN int
libwebsockets_get_random(struct libwebsocket_context *context,
void *buf, int len);
LWS_EXTERN int
lws_daemonize(const char *_lock_path);
LWS_EXTERN int
lws_send_pipe_choked(struct libwebsocket *wsi);
LWS_EXTERN int
lws_frame_is_binary(struct libwebsocket *wsi);
LWS_EXTERN unsigned char *
libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);
LWS_EXTERN int
lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
LWS_EXTERN int
lws_b64_decode_string(const char *in, char *out, int out_size);
LWS_EXTERN const char *
lws_get_library_version(void);
/* access to headers... only valid while headers valid */
LWS_EXTERN int
lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h);
LWS_EXTERN int
lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
enum lws_token_indexes h);
/*
* Note: this is not normally needed as a user api. It's provided in case it is
* useful when integrating with other app poll loop service code.
*/
LWS_EXTERN int
libwebsocket_read(struct libwebsocket_context *context,
struct libwebsocket *wsi,
unsigned char *buf, size_t len);
#ifndef LWS_NO_EXTENSIONS
LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions();
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1 @@
2e9ff412352827591ef1389f336b01d179260293

View File

@ -187,10 +187,7 @@
DSTROOT = /tmp/libPluginFlurry.dst; DSTROOT = /tmp/libPluginFlurry.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/../platform/ios\"", "\"$(SRCROOT)/../platform/ios\"",
@ -209,10 +206,7 @@
DSTROOT = /tmp/libPluginFlurry.dst; DSTROOT = /tmp/libPluginFlurry.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)/../platform/ios\"", "\"$(SRCROOT)/../platform/ios\"",

View File

@ -0,0 +1,385 @@
//
// FHSTwitterEngine.h
// FHSTwitterEngine
//
// Created by Nathaniel Symer on 8/22/12.
// Copyright (C) 2012 Nathaniel Symer.
//
// 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.
//
//
// //// FHSTwitterEngine Version 1.6.1 ////
// Modified OAuthConsumer Version 1.2.2
//
//
//
// FHSTwitterEngine
// The synchronous Twitter engine that doesnt suck!!
//
// FHSTwitterEngine is Synchronous
// That means you will have to thread. Boo Hoo.
// Setup
// Just add the FHSTwitterEngine folder to you project.
// USAGE
// See README.markdown
//
// NOTE TO CONTRIBUTORS
// Use NSJSONSerialization with removeNull(). Life is easy that way.
//
#import <Foundation/Foundation.h>
// These are for the dispatch_async() calls that you use to get around the synchronous-ness
#define GCDBackgroundThread dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define GCDMainThread dispatch_get_main_queue()
// oEmbed align modes
typedef enum {
FHSTwitterEngineAlignModeLeft,
FHSTwitterEngineAlignModeRight,
FHSTwitterEngineAlignModeCenter,
FHSTwitterEngineAlignModeNone
} FHSTwitterEngineAlignMode;
// Image sizes
typedef enum {
FHSTwitterEngineImageSizeMini, // 24px by 24px
FHSTwitterEngineImageSizeNormal, // 48x48
FHSTwitterEngineImageSizeBigger, // 73x73
FHSTwitterEngineImageSizeOriginal // original size of image
} FHSTwitterEngineImageSize;
typedef enum {
FHSTwitterEngineResultTypeMixed,
FHSTwitterEngineResultTypeRecent,
FHSTwitterEngineResultTypePopular
} FHSTwitterEngineResultType;
// Remove NSNulls from NSDictionary and NSArray
// Credit for this function goes to Conrad Kramer
id removeNull(id rootObject);
extern NSString * const FHSProfileBackgroundColorKey;
extern NSString * const FHSProfileLinkColorKey;
extern NSString * const FHSProfileSidebarBorderColorKey;
extern NSString * const FHSProfileSidebarFillColorKey;
extern NSString * const FHSProfileTextColorKey;
extern NSString * const FHSProfileNameKey;
extern NSString * const FHSProfileURLKey;
extern NSString * const FHSProfileLocationKey;
extern NSString * const FHSProfileDescriptionKey;
@protocol FHSTwitterEngineAccessTokenDelegate <NSObject>
- (void)storeAccessToken:(NSString *)accessToken;
- (NSString *)loadAccessToken;
@end
@class OAToken;
@class OAConsumer;
@class OAMutableURLRequest;
@interface FHSTwitterEngine : NSObject <UIWebViewDelegate>
//
// REST API
//
// statuses/update
- (NSError *)postTweet:(NSString *)tweetString;
- (NSError *)postTweet:(NSString *)tweetString inReplyTo:(NSString *)inReplyToString;
// statuses/home_timeline
- (id)getHomeTimelineSinceID:(NSString *)sinceID count:(int)count;
// help/test
- (id)testService;
// blocks/create
- (NSError *)block:(NSString *)username;
// blocks/destroy
- (NSError *)unblock:(NSString *)username;
// users/lookup
- (id)lookupUsers:(NSArray *)users areIDs:(BOOL)areIDs;
// users/search
- (id)searchUsersWithQuery:(NSString *)q andCount:(int)count;
// account/update_profile_image
- (NSError *)setProfileImageWithImageAtPath:(NSString *)file;
- (NSError *)setProfileImageWithImageData:(NSData *)data;
// account/settings GET and POST
// See FHSTwitterEngine.m For details
- (id)getUserSettings;
- (NSError *)updateSettingsWithDictionary:(NSDictionary *)settings;
// account/update_profile
// See FHSTwitterEngine.m for details
- (NSError *)updateUserProfileWithDictionary:(NSDictionary *)settings;
// account/update_profile_background_image
- (NSError *)setProfileBackgroundImageWithImageData:(NSData *)data tiled:(BOOL)isTiled;
- (NSError *)setProfileBackgroundImageWithImageAtPath:(NSString *)file tiled:(BOOL)isTiled;
- (NSError *)setUseProfileBackgroundImage:(BOOL)shouldUseProfileBackgroundImage;
// account/update_profile_colors
// See FHSTwitterEngine.m for details
// If the dictionary is nil, FHSTwitterEngine resets the values
- (NSError *)updateProfileColorsWithDictionary:(NSDictionary *)dictionary;
// account/rate_limit_status
- (id)getRateLimitStatus;
// favorites/create, favorites/destroy
- (NSError *)markTweet:(NSString *)tweetID asFavorite:(BOOL)flag;
// favorites/list
- (id)getFavoritesForUser:(NSString *)user isID:(BOOL)isID andCount:(int)count;
- (id)getFavoritesForUser:(NSString *)user isID:(BOOL)isID andCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
// account/verify_credentials
- (id)verifyCredentials;
// friendships/create
- (NSError *)followUser:(NSString *)user isID:(BOOL)isID;
// friendships/destroy
- (NSError *)unfollowUser:(NSString *)user isID:(BOOL)isID;
// friendships/lookup
- (id)lookupFriendshipStatusForUsers:(NSArray *)users areIDs:(BOOL)areIDs;
// friendships/incoming
- (id)getPendingIncomingFollowers;
// friendships/outgoing
- (id)getPendingOutgoingFollowers;
// friendships/update
- (NSError *)enableRetweets:(BOOL)enableRTs andDeviceNotifs:(BOOL)devNotifs forUser:(NSString *)user isID:(BOOL)isID;
// friendships/no_retweet_ids
- (id)getNoRetweetIDs;
// help/tos
- (id)getTermsOfService;
// help/privacy
- (id)getPrivacyPolicy;
// direct_messages
- (id)getDirectMessages:(int)count;
// direct_messages/destroy
- (NSError *)deleteDirectMessage:(NSString *)messageID;
// direct_messages/sent
- (id)getSentDirectMessages:(int)count;
// direct_messages/new
- (NSError *)sendDirectMessage:(NSString *)body toUser:(NSString *)user isID:(BOOL)isID;
// direct_messages/show
- (id)showDirectMessage:(NSString *)messageID;
// users/report_spam
- (NSError *)reportUserAsSpam:(NSString *)user isID:(BOOL)isID;
// help/configuration
- (id)getConfiguration;
// help/languages
- (id)getLanguages;
// blocks/blocking/ids
- (id)listBlockedIDs;
// blocks/blocking
- (id)listBlockedUsers;
// blocks/exists
- (id)authenticatedUserIsBlocking:(NSString *)user isID:(BOOL)isID;
// users/profile_image
- (id)getProfileImageForUsername:(NSString *)username andSize:(FHSTwitterEngineImageSize)size;
// statuses/user_timeline
- (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count;
- (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
// statuses/retweet
- (NSError *)retweet:(NSString *)identifier;
// statuses/oembed
- (id)oembedTweet:(NSString *)identifier maxWidth:(float)maxWidth alignmentMode:(FHSTwitterEngineAlignMode)alignmentMode;
// statuses/show
- (id)getDetailsForTweet:(NSString *)identifier;
// statuses/destroy
- (NSError *)destroyTweet:(NSString *)identifier;
// statuses/update_with_media
- (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData;
- (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData inReplyTo:(NSString *)irt;
// statuses/mentions_timeline
- (id)getMentionsTimelineWithCount:(int)count;
- (id)getMentionsTimelineWithCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
// statuses/retweets_of_me
- (id)getRetweetedTimelineWithCount:(int)count;
- (id)getRetweetedTimelineWithCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
// statuses/retweets
- (id)getRetweetsForTweet:(NSString *)identifier count:(int)count;
// lists/list
- (id)getListsForUser:(NSString *)user isID:(BOOL)isID;
// lists/statuses
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count;
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count excludeRetweets:(BOOL)excludeRetweets excludeReplies:(BOOL)excludeReplies;
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID excludeRetweets:(BOOL)excludeRetweets excludeReplies:(BOOL)excludeReplies;
// lists/members/create_all
- (NSError *)addUsersToListWithID:(NSString *)listID users:(NSArray *)users;
// lists/members/destroy_all
- (NSError *)removeUsersFromListWithID:(NSString *)listID users:(NSArray *)users;
// lists/members
- (id)listUsersInListWithID:(NSString *)listID;
// lists/update
- (NSError *)setModeOfListWithID:(NSString *)listID toPrivate:(BOOL)isPrivate;
- (NSError *)changeNameOfListWithID:(NSString *)listID toName:(NSString *)newName;
- (NSError *)changeDescriptionOfListWithID:(NSString *)listID toDescription:(NSString *)newName;
// lists/show
- (id)getListWithID:(NSString *)listID;
// lists/create
- (NSError *)createListWithName:(NSString *)name isPrivate:(BOOL)isPrivate description:(NSString *)description;
// tweets/search
- (id)searchTweetsWithQuery:(NSString *)q count:(int)count resultType:(FHSTwitterEngineResultType)resultType unil:(NSDate *)untilDate sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
// followers/ids
- (id)getFollowersIDs;
// followers/list
- (id)listFollowersForUser:(NSString *)user isID:(BOOL)isID withCursor:(NSString *)cursor;
// friends/ids
- (id)getFriendsIDs;
// friends/list
- (id)listFriendsForUser:(NSString *)user isID:(BOOL)isID withCursor:(NSString *)cursor;
//
// Login and Auth
//
// XAuth login
- (NSError *)getXAuthAccessTokenForUsername:(NSString *)username password:(NSString *)password;
// OAuth login
- (void)showOAuthLoginControllerFromViewController:(UIViewController *)sender;
- (void)showOAuthLoginControllerFromViewController:(UIViewController *)sender withCompletion:(void(^)(BOOL success))completionBlock;
// Access Token Mangement
- (void)clearAccessToken;
- (void)loadAccessToken;
- (BOOL)isAuthorized;
// Clear Keys
- (void)clearConsumer;
// sendRequest methods, use these for every request
- (NSError *)sendPOSTRequest:(OAMutableURLRequest *)request withParameters:(NSArray *)params;
- (id)sendGETRequest:(OAMutableURLRequest *)request withParameters:(NSArray *)params;
//
// Misc Methods
//
// Date parser
- (NSDate *)getDateFromTwitterCreatedAt:(NSString *)twitterDate;
// id list generator - returns an array of id/username list strings
- (NSArray *)generateRequestStringsFromArray:(NSArray *)array;
// Temporaryily set keys
// if you don't want your keys in memory, simply use
// this method. You will have to use it before
// making any API calls.
- (void)temporarilySetConsumerKey:(NSString *)consumerKey andSecret:(NSString *)consumerSecret;
// Use to set the consumer key when using the singleton
- (void)permanentlySetConsumerKey:(NSString *)consumerKey andSecret:(NSString *)consumerSecret;
// Singleton, NEVER use the -init method. Ever.
+ (FHSTwitterEngine *)sharedEngine;
// Determines your internet status
+ (BOOL)isConnectedToInternet;
// Determines if entities should be included
@property (nonatomic, assign) BOOL includeEntities;
// Logged in user's username
@property (nonatomic, retain) NSString *loggedInUsername;
// Logged in user's Twitter ID
@property (nonatomic, retain) NSString *loggedInID;
// Will be called to store the accesstoken
@property (nonatomic, assign) id<FHSTwitterEngineAccessTokenDelegate> delegate;
// Access Token
@property (nonatomic, retain) OAToken *accessToken;
@end
@interface NSData (Base64)
+ (NSData *)dataWithBase64EncodedString:(NSString *)string;
- (id)initWithBase64EncodedString:(NSString *)string;
- (NSString *)base64EncodingWithLineLength:(unsigned int)lineLength;
@end
@interface NSString (FHSTwitterEngine)
- (NSString *)fhs_trimForTwitter;
- (NSString *)fhs_stringWithRange:(NSRange)range;
- (BOOL)fhs_isNumeric;
@end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
//
// NSString+URLEncoding.h
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface NSString (OAURLEncodingAdditions)
- (NSString *)URLEncodedString;
- (NSString *)URLDecodedString;
@end

View File

@ -0,0 +1,44 @@
//
// NSString+URLEncoding.m
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "NSString+URLEncoding.h"
@implementation NSString (OAURLEncodingAdditions)
- (NSString *)URLEncodedString {
CFStringRef url = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8); // for some reason, releasing this is disasterous
NSString *result = (NSString *)url;
[result autorelease];
return result;
}
- (NSString *)URLDecodedString {
CFStringRef url = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)self, CFSTR(""), kCFStringEncodingUTF8);
NSString *result = (NSString *)url;
[result autorelease];
return result;
}
@end

View File

@ -0,0 +1,225 @@
/*
* Base64Transcoder.c
* Base64Test
*
* Created by Jonathan Wight on Tue Mar 18 2003.
* Copyright (c) 2003 Toxic Software. All rights reserved.
*
* 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 "Base64TranscoderFHS.h"
#include <math.h>
#include <string.h>
const u_int8_t kBase64EncodeTable_[64] = {
/* 0 */ 'A', /* 1 */ 'B', /* 2 */ 'C', /* 3 */ 'D',
/* 4 */ 'E', /* 5 */ 'F', /* 6 */ 'G', /* 7 */ 'H',
/* 8 */ 'I', /* 9 */ 'J', /* 10 */ 'K', /* 11 */ 'L',
/* 12 */ 'M', /* 13 */ 'N', /* 14 */ 'O', /* 15 */ 'P',
/* 16 */ 'Q', /* 17 */ 'R', /* 18 */ 'S', /* 19 */ 'T',
/* 20 */ 'U', /* 21 */ 'V', /* 22 */ 'W', /* 23 */ 'X',
/* 24 */ 'Y', /* 25 */ 'Z', /* 26 */ 'a', /* 27 */ 'b',
/* 28 */ 'c', /* 29 */ 'd', /* 30 */ 'e', /* 31 */ 'f',
/* 32 */ 'g', /* 33 */ 'h', /* 34 */ 'i', /* 35 */ 'j',
/* 36 */ 'k', /* 37 */ 'l', /* 38 */ 'm', /* 39 */ 'n',
/* 40 */ 'o', /* 41 */ 'p', /* 42 */ 'q', /* 43 */ 'r',
/* 44 */ 's', /* 45 */ 't', /* 46 */ 'u', /* 47 */ 'v',
/* 48 */ 'w', /* 49 */ 'x', /* 50 */ 'y', /* 51 */ 'z',
/* 52 */ '0', /* 53 */ '1', /* 54 */ '2', /* 55 */ '3',
/* 56 */ '4', /* 57 */ '5', /* 58 */ '6', /* 59 */ '7',
/* 60 */ '8', /* 61 */ '9', /* 62 */ '+', /* 63 */ '/'
};
/*
-1 = Base64 end of data marker.
-2 = White space (tabs, cr, lf, space)
-3 = Noise (all non whitespace, non-base64 characters)
-4 = Dangerous noise
-5 = Illegal noise (null byte)
*/
const int8_t kBase64DecodeTable_[128] = {
/* 0x00 */ -5, /* 0x01 */ -3, /* 0x02 */ -3, /* 0x03 */ -3,
/* 0x04 */ -3, /* 0x05 */ -3, /* 0x06 */ -3, /* 0x07 */ -3,
/* 0x08 */ -3, /* 0x09 */ -2, /* 0x0a */ -2, /* 0x0b */ -2,
/* 0x0c */ -2, /* 0x0d */ -2, /* 0x0e */ -3, /* 0x0f */ -3,
/* 0x10 */ -3, /* 0x11 */ -3, /* 0x12 */ -3, /* 0x13 */ -3,
/* 0x14 */ -3, /* 0x15 */ -3, /* 0x16 */ -3, /* 0x17 */ -3,
/* 0x18 */ -3, /* 0x19 */ -3, /* 0x1a */ -3, /* 0x1b */ -3,
/* 0x1c */ -3, /* 0x1d */ -3, /* 0x1e */ -3, /* 0x1f */ -3,
/* ' ' */ -2, /* '!' */ -3, /* '"' */ -3, /* '#' */ -3,
/* '$' */ -3, /* '%' */ -3, /* '&' */ -3, /* ''' */ -3,
/* '(' */ -3, /* ')' */ -3, /* '*' */ -3, /* '+' */ 62,
/* ',' */ -3, /* '-' */ -3, /* '.' */ -3, /* '/' */ 63,
/* '0' */ 52, /* '1' */ 53, /* '2' */ 54, /* '3' */ 55,
/* '4' */ 56, /* '5' */ 57, /* '6' */ 58, /* '7' */ 59,
/* '8' */ 60, /* '9' */ 61, /* ':' */ -3, /* ';' */ -3,
/* '<' */ -3, /* '=' */ -1, /* '>' */ -3, /* '?' */ -3,
/* '@' */ -3, /* 'A' */ 0, /* 'B' */ 1, /* 'C' */ 2,
/* 'D' */ 3, /* 'E' */ 4, /* 'F' */ 5, /* 'G' */ 6,
/* 'H' */ 7, /* 'I' */ 8, /* 'J' */ 9, /* 'K' */ 10,
/* 'L' */ 11, /* 'M' */ 12, /* 'N' */ 13, /* 'O' */ 14,
/* 'P' */ 15, /* 'Q' */ 16, /* 'R' */ 17, /* 'S' */ 18,
/* 'T' */ 19, /* 'U' */ 20, /* 'V' */ 21, /* 'W' */ 22,
/* 'X' */ 23, /* 'Y' */ 24, /* 'Z' */ 25, /* '[' */ -3,
/* '\' */ -3, /* ']' */ -3, /* '^' */ -3, /* '_' */ -3,
/* '`' */ -3, /* 'a' */ 26, /* 'b' */ 27, /* 'c' */ 28,
/* 'd' */ 29, /* 'e' */ 30, /* 'f' */ 31, /* 'g' */ 32,
/* 'h' */ 33, /* 'i' */ 34, /* 'j' */ 35, /* 'k' */ 36,
/* 'l' */ 37, /* 'm' */ 38, /* 'n' */ 39, /* 'o' */ 40,
/* 'p' */ 41, /* 'q' */ 42, /* 'r' */ 43, /* 's' */ 44,
/* 't' */ 45, /* 'u' */ 46, /* 'v' */ 47, /* 'w' */ 48,
/* 'x' */ 49, /* 'y' */ 50, /* 'z' */ 51, /* '{' */ -3,
/* '|' */ -3, /* '}' */ -3, /* '~' */ -3, /* 0x7f */ -3
};
const u_int8_t kBits_00000011_ = 0x03;
const u_int8_t kBits_00001111_ = 0x0F;
const u_int8_t kBits_00110000_ = 0x30;
const u_int8_t kBits_00111100_ = 0x3C;
const u_int8_t kBits_00111111_ = 0x3F;
const u_int8_t kBits_11000000_ = 0xC0;
const u_int8_t kBits_11110000_ = 0xF0;
const u_int8_t kBits_11111100_ = 0xFC;
size_t EstimateBas64EncodedDataSizeFHS(size_t inDataSize) {
size_t theEncodedDataSize = (int)ceil(inDataSize / 3.0) * 4;
theEncodedDataSize = theEncodedDataSize / 72 * 74 + theEncodedDataSize % 72;
return(theEncodedDataSize);
}
size_t EstimateBas64DecodedDataSizeFHS(size_t inDataSize) {
size_t theDecodedDataSize = (int)ceil(inDataSize / 4.0) * 3;
//theDecodedDataSize = theDecodedDataSize / 72 * 74 + theDecodedDataSize % 72;
return(theDecodedDataSize);
}
bool Base64EncodeDataFHS(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize) {
size_t theEncodedDataSize = EstimateBas64EncodedDataSizeFHS(inInputDataSize);
if (*ioOutputDataSize < theEncodedDataSize) {
return false;
}
*ioOutputDataSize = theEncodedDataSize;
const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
u_int32_t theInIndex = 0, theOutIndex = 0;
for (; theInIndex < (inInputDataSize / 3) * 3; theInIndex += 3) {
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000_) >> 4];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 1] & kBits_00001111_) << 2 | (theInPtr[theInIndex + 2] & kBits_11000000_) >> 6];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 2] & kBits_00111111_) >> 0];
if (theOutIndex % 74 == 72) {
outOutputData[theOutIndex++] = '\r';
outOutputData[theOutIndex++] = '\n';
}
}
const size_t theRemainingBytes = inInputDataSize - theInIndex;
if (theRemainingBytes == 1) {
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (0 & kBits_11110000_) >> 4];
outOutputData[theOutIndex++] = '=';
outOutputData[theOutIndex++] = '=';
if (theOutIndex % 74 == 72) {
outOutputData[theOutIndex++] = '\r';
outOutputData[theOutIndex++] = '\n';
}
} else if (theRemainingBytes == 2) {
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000_) >> 4];
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 1] & kBits_00001111_) << 2 | (0 & kBits_11000000_) >> 6];
outOutputData[theOutIndex++] = '=';
if (theOutIndex % 74 == 72) {
outOutputData[theOutIndex++] = '\r';
outOutputData[theOutIndex++] = '\n';
}
}
return true;
}
bool Base64DecodeData_(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize) {
memset(ioOutputData, '.', *ioOutputDataSize);
size_t theDecodedDataSize = EstimateBas64DecodedDataSizeFHS(inInputDataSize);
if (*ioOutputDataSize < theDecodedDataSize) {
return false;
}
*ioOutputDataSize = 0;
const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
u_int8_t *theOutPtr = (u_int8_t *)ioOutputData;
size_t theInIndex = 0, theOutIndex = 0;
u_int8_t theOutputOctet;
size_t theSequence = 0;
for (; theInIndex < inInputDataSize; ) {
int8_t theSextet = 0;
int8_t theCurrentInputOctet = theInPtr[theInIndex];
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
if (theSextet == -1) {
break;
}
while (theSextet == -2) {
theCurrentInputOctet = theInPtr[++theInIndex];
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
}
while (theSextet == -3) {
theCurrentInputOctet = theInPtr[++theInIndex];
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
}
if (theSequence == 0) {
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 2 & kBits_11111100_;
} else if (theSequence == 1) {
theOutputOctet |= (theSextet >- 0 ? theSextet : 0) >> 4 & kBits_00000011_;
theOutPtr[theOutIndex++] = theOutputOctet;
} else if (theSequence == 2) {
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 4 & kBits_11110000_;
} else if (theSequence == 3) {
theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 2 & kBits_00001111_;
theOutPtr[theOutIndex++] = theOutputOctet;
} else if (theSequence == 4) {
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 6 & kBits_11000000_;
} else if (theSequence == 5) {
theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 0 & kBits_00111111_;
theOutPtr[theOutIndex++] = theOutputOctet;
}
theSequence = (theSequence+1)%6;
if (theSequence != 2 && theSequence != 4) {
theInIndex++;
}
}
*ioOutputDataSize = theOutIndex;
return true;
}

View File

@ -0,0 +1,36 @@
/*
* Base64Transcoder.h
* Base64Test
*
* Created by Jonathan Wight on Tue Mar 18 2003.
* Copyright (c) 2003 Toxic Software. All rights reserved.
*
* 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 <stdlib.h>
#include <stdbool.h>
extern size_t EstimateBas64EncodedDataSizeFHS(size_t inDataSize);
extern size_t EstimateBas64DecodedDataSizeFHS(size_t inDataSize);
extern bool Base64EncodeDataFHS(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize);
extern bool Base64DecodeDataFHS(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize);

View File

@ -0,0 +1,38 @@
//
// OAConsumer.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface OAConsumer : NSObject
@property (nonatomic, retain) NSString *key;
@property (nonatomic, retain) NSString *secret;
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
+ (OAConsumer *)consumerWithKey:(NSString *)aKey secret:(NSString *)aSecret;
@end

View File

@ -0,0 +1,48 @@
//
// OAConsumer.m
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OAConsumer.h"
@implementation OAConsumer
+ (OAConsumer *)consumerWithKey:(NSString *)aKey secret:(NSString *)aSecret {
return [[[[self class]alloc]initWithKey:aKey secret:aSecret]autorelease];
}
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret {
if (self = [super init]) {
self.key = aKey;
self.secret = aSecret;
}
return self;
}
- (void)dealloc {
[self setKey:nil];
[self setSecret:nil];
[super dealloc];
}
@end

View File

@ -0,0 +1,38 @@
//
// OAHMAC_SHA1SignatureProvider.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@protocol OASignatureProviding <NSObject>
- (NSString *)name;
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret;
@end
@interface OAHMAC_SHA1SignatureProvider : NSObject <OASignatureProviding>
+ (OAHMAC_SHA1SignatureProvider *)OAHMAC_SHA1SignatureProvider;
@end

View File

@ -0,0 +1,60 @@
//
// OAHMAC_SHA1SignatureProvider.m
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OAHMAC_SHA1SignatureProvider.h"
#import <CommonCrypto/CommonHMAC.h>
#include "Base64TranscoderFHS.h"
@implementation OAHMAC_SHA1SignatureProvider
+ (OAHMAC_SHA1SignatureProvider *)OAHMAC_SHA1SignatureProvider {
return [[[[self class]alloc]init]autorelease];
}
- (NSString *)name {
return @"HMAC-SHA1";
}
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret {
NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];
NSData *clearTextData = [text dataUsingEncoding:NSUTF8StringEncoding];
unsigned char result[20];
CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], result);
// Base64 Encoding
char base64Result[32];
size_t theResultLength = 32;
Base64EncodeDataFHS(result, 20, base64Result, &theResultLength);
NSData *theData = [NSData dataWithBytes:base64Result length:theResultLength];
NSString *base64EncodedResult = [[NSString alloc]initWithData:theData encoding:NSUTF8StringEncoding];
return [base64EncodedResult autorelease];
}
@end

View File

@ -0,0 +1,55 @@
//
// OAMutableURLRequest.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "OAConsumer.h"
#import "OAToken.h"
#import "OAHMAC_SHA1SignatureProvider.h"
@class OAServiceTicket;
@interface OAMutableURLRequest : NSMutableURLRequest
@property (nonatomic, assign) NSString *signature;
@property (nonatomic, assign) NSString *nonce;
@property (nonatomic, assign) NSString *timestamp;
+ (void)fetchDataForRequest:(OAMutableURLRequest *)request withCompletionHandler:(void(^)(OAServiceTicket *, NSData *, NSError *))block;
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider;
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken;
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider;
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider nonce:(NSString *)aNonce timestamp:(NSString *)aTimestamp;
- (void)prepare;
- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue;
- (NSArray *)parameters;
- (void)setParameters:(NSArray *)parameters;
@end

View File

@ -0,0 +1,296 @@
//
// OAMutableURLRequest.m
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OAMutableURLRequest.h"
#import "OARequestParameter.h"
#import "OAServiceTicket.h"
@interface OAMutableURLRequest ()
- (void)_generateTimestamp;
- (void)_generateNonce;
- (NSString *)_signatureBaseString;
@property (nonatomic, retain) OAConsumer *consumer;
@property (nonatomic, retain) OAToken *token;
@property (nonatomic, retain) NSString *realm;
@property (nonatomic, retain) id <OASignatureProviding> signatureProvider;
@property (nonatomic, retain) NSMutableDictionary *extraOAuthParameters;
@end
@interface NSURL (OABaseAdditions)
- (NSString *)URLStringWithoutQuery;
@end
@implementation NSURL (OABaseAdditions)
- (NSString *)URLStringWithoutQuery {
if (self.absoluteString.length == 0) {
return nil;
}
NSArray *parts = [self.absoluteString componentsSeparatedByString:@"?"];
return (parts.count == 0)?nil:[parts objectAtIndex:0];
}
@end
@implementation OAMutableURLRequest
+ (void)fetchDataForRequest:(OAMutableURLRequest *)request withCompletionHandler:(void(^)(OAServiceTicket *, NSData *, NSError *))block {
[request prepare];
[NSURLConnection sendAsynchronousRequest:request queue:[[[NSOperationQueue alloc]init]autorelease] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
OAServiceTicket *ticket = [[[OAServiceTicket alloc]initWithRequest:request response:response didSucceed:(error == nil)]autorelease];
block(ticket, data, error);
}];
}
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken {
return [[[[self class]alloc]initWithURL:aUrl consumer:aConsumer token:aToken realm:nil signatureProvider:nil]autorelease];
}
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider {
return [[[[self class]alloc]initWithURL:aUrl consumer:aConsumer token:aToken realm:aRealm signatureProvider:aProvider]autorelease];
}
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider {
self = [super initWithURL:aUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:25];
if (self) {
[self setConsumer:aConsumer];
// empty token for Unauthorized Request Token transaction
if (aToken == nil) {
[self setToken:[OAToken token]];
} else {
[self setToken:aToken];
}
if (aRealm == nil) {
[self setRealm:@""];
} else {
[self setRealm:aRealm];
}
// default to HMAC-SHA1
if (aProvider == nil) {
[self setSignatureProvider:[OAHMAC_SHA1SignatureProvider OAHMAC_SHA1SignatureProvider]];
} else {
[self setSignatureProvider:aProvider];
}
[self _generateTimestamp];
[self _generateNonce];
}
return self;
}
// Setting a timestamp and nonce to known values. Can be helpful for testing
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider nonce:(NSString *)aNonce timestamp:(NSString *)aTimestamp {
self = [super initWithURL:aUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
if (self) {
[self setConsumer:aConsumer];
// empty token for Unauthorized Request Token transaction
if (aToken == nil) {
[self setToken:[OAToken token]];
} else {
[self setToken:aToken];
}
if (aRealm == nil) {
[self setRealm:@""];
} else {
[self setRealm:aRealm];
}
// default to HMAC-SHA1
if (aProvider == nil) {
[self setSignatureProvider:[OAHMAC_SHA1SignatureProvider OAHMAC_SHA1SignatureProvider]];
} else {
[self setSignatureProvider:aProvider];
}
[self setTimestamp:aTimestamp];
[self setNonce:aNonce];
}
return self;
}
- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue {
if (!parameterName && !parameterValue) {
NSLog(@"%s There was not parameter name nor value specified.", __PRETTY_FUNCTION__);
return;
}
if (self.extraOAuthParameters == nil) {
[self setExtraOAuthParameters:[NSMutableDictionary dictionary]];
}
[self.extraOAuthParameters setObject:parameterValue forKey:parameterName];
}
- (void)prepare {
// sign
// Secrets must be urlencoded before concatenated with '&'
// TODO: if later RSA-SHA1 support is added then a little code redesign is needed
self.signature = [self.signatureProvider signClearText:[self _signatureBaseString] withSecret:[NSString stringWithFormat:@"%@&%@", [self.consumer.secret URLEncodedString], [self.token.secret URLEncodedString]]];
// set OAuth headers
NSString *oauthToken;
if ([self.token.key isEqualToString:@""]) {
oauthToken = @"oauth_callback=\"oob\", ";
} else if (self.token.verifier.length == 0) {
oauthToken = [NSString stringWithFormat:@"oauth_token=\"%@\", ", [self.token.key URLEncodedString]];
} else {
oauthToken = [NSString stringWithFormat:@"oauth_token=\"%@\", oauth_verifier=\"%@\", ", [self.token.key URLEncodedString], [self.token.verifier URLEncodedString]];
}
NSMutableString *extraParameters = [NSMutableString string];
// Adding the optional parameters in sorted order isn't required by the OAuth spec, but it makes it possible to hard-code expected values in the unit tests.
for (NSString *parameterName in [[self.extraOAuthParameters allKeys]sortedArrayUsingSelector:@selector(compare:)]) {
[extraParameters appendFormat:@", %@=\"%@\"",[parameterName URLEncodedString],[[self.extraOAuthParameters objectForKey:parameterName]URLEncodedString]];
}
NSString *oauthHeader = [NSString stringWithFormat:@"OAuth realm=\"%@\", oauth_consumer_key=\"%@\", %@oauth_signature_method=\"%@\", oauth_signature=\"%@\", oauth_timestamp=\"%@\", oauth_nonce=\"%@\", oauth_version=\"1.0\"%@", [self.realm URLEncodedString], [self.consumer.key URLEncodedString], oauthToken, [[self.signatureProvider name] URLEncodedString], [self.signature URLEncodedString], self.timestamp, self.nonce, extraParameters];
[self setValue:oauthHeader forHTTPHeaderField:@"Authorization"];
}
- (NSArray *)parameters {
NSString *encodedParameters = nil;
if ([self.HTTPMethod isEqualToString:@"GET"] || [self.HTTPMethod isEqualToString:@"DELETE"]) {
encodedParameters = self.URL.query;
} else if ([self.HTTPMethod isEqualToString:@"POST"] || [self.HTTPMethod isEqualToString:@"PUT"]) {
encodedParameters = [[[NSString alloc]initWithData:self.HTTPBody encoding:NSASCIIStringEncoding]autorelease];
}
if (encodedParameters.length == 0) {
return nil;
}
NSArray *encodedParameterPairs = [encodedParameters componentsSeparatedByString:@"&"];
NSMutableArray *requestParameters = [NSMutableArray arrayWithCapacity:16];
for (NSString *encodedPair in encodedParameterPairs) {
NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="];
OARequestParameter *parameter = [OARequestParameter requestParameterWithName:[[encodedPairElements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] value:[[encodedPairElements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[requestParameters addObject:parameter];
}
return requestParameters;
}
- (void)setParameters:(NSArray *)parameters {
NSMutableString *encodedParameterPairs = [NSMutableString stringWithCapacity:256];
int position = 1;
for (OARequestParameter *requestParameter in parameters) {
[encodedParameterPairs appendString:[requestParameter URLEncodedNameValuePair]];
if (position < parameters.count) {
[encodedParameterPairs appendString:@"&"];
}
position++;
}
if ([self.HTTPMethod isEqualToString:@"GET"] || [self.HTTPMethod isEqualToString:@"DELETE"]) {
[self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [self.URL URLStringWithoutQuery], encodedParameterPairs]]];
} else if ([self.HTTPMethod isEqualToString:@"POST"] || [self.HTTPMethod isEqualToString:@"PUT"]) {
NSData *postData = [encodedParameterPairs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[self setHTTPBody:postData];
[self setValue:[NSString stringWithFormat:@"%d",postData.length] forHTTPHeaderField:@"Content-Length"];
[self setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
}
}
- (void)_generateTimestamp {
[self setTimestamp:[NSString stringWithFormat:@"%ld", time(nil)]];
}
- (void)_generateNonce {
CFUUIDRef theUUID = CFUUIDCreate(nil);
CFStringRef string = CFUUIDCreateString(nil, theUUID);
CFRelease(theUUID);
[self setNonce:[NSString stringWithString:(NSString *)string]];
CFRelease(string);
}
- (NSString *)_signatureBaseString {
// OAuth Spec, Section 9.1.1 "Normalize Request Parameters"
// build a sorted array of both request parameters and OAuth header parameters
NSArray *parameters = [self parameters];
NSMutableArray *parameterPairs = [NSMutableArray arrayWithCapacity:(6+parameters.count)]; // 6 being the number of OAuth params in the Signature Base String
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_consumer_key" value:self.consumer.key]URLEncodedNameValuePair]];
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_signature_method" value:[self.signatureProvider name]] URLEncodedNameValuePair]];
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_timestamp" value:self.timestamp]URLEncodedNameValuePair]];
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_nonce" value:self.nonce]URLEncodedNameValuePair]];
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_version" value:@"1.0"]URLEncodedNameValuePair]];
if (self.token.key.length > 0) {
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_token" value:self.token.key]URLEncodedNameValuePair]];
if (self.token.verifier.length > 0) {
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_verifier" value:self.token.verifier]URLEncodedNameValuePair]];
}
} else {
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_callback" value:@"oob"]URLEncodedNameValuePair]];
}
for (OARequestParameter *param in parameters) {
[parameterPairs addObject:[param URLEncodedNameValuePair]];
}
NSArray *sortedPairs = [parameterPairs sortedArrayUsingSelector:@selector(compare:)];
NSString *normalizedRequestParameters = [sortedPairs componentsJoinedByString:@"&"];
// OAuth Spec, Section 9.1.2 "Concatenate Request Elements"
NSString *ret = [NSString stringWithFormat:@"%@&%@&%@", self.HTTPMethod, [[self.URL URLStringWithoutQuery]URLEncodedString], [normalizedRequestParameters URLEncodedString]];
return ret;
}
- (void)dealloc {
[self setExtraOAuthParameters:nil];
[self setConsumer:nil];
[self setToken:nil];
[self setRealm:nil];
[self setSignatureProvider:nil];
[self setTimestamp:nil];
[self setNonce:nil];
[self setSignature:nil];
[super dealloc];
}
@end

View File

@ -0,0 +1,41 @@
//
// OARequestParameter.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "NSString+URLEncoding.h"
@interface OARequestParameter : NSObject
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *value;
+ (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue;
- (id)initWithName:(NSString *)aName value:(NSString *)aValue;
- (NSString *)URLEncodedName;
- (NSString *)URLEncodedValue;
- (NSString *)URLEncodedNameValuePair;
@end

View File

@ -0,0 +1,62 @@
//
// OARequestParameter.m
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OARequestParameter.h"
@implementation OARequestParameter
+ (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue {
return [[[[self class]alloc]initWithName:aName value:aValue]autorelease];
}
- (id)initWithName:(NSString *)aName value:(NSString *)aValue {
if (self = [super init]) {
self.name = aName;
self.value = aValue;
}
return self;
}
- (NSString *)URLEncodedName {
return [self.name URLEncodedString];
}
- (NSString *)URLEncodedValue {
return [self.value URLEncodedString];
}
- (NSString *)URLEncodedNameValuePair {
return [NSString stringWithFormat:@"%@=%@", [self URLEncodedName], [self URLEncodedValue]];
}
- (void)dealloc {
[self setName:nil];
[self setValue:nil];
[super dealloc];
}
@end

View File

@ -0,0 +1,39 @@
//
// OAServiceTicket.h
// OAuthConsumer
//
// Created by Jon Crosby on 11/5/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "OAMutableURLRequest.h"
@interface OAServiceTicket : NSObject
@property (nonatomic, retain) OAMutableURLRequest *request;
@property (nonatomic, retain) NSURLResponse *response;
@property (nonatomic, assign) BOOL didSucceed;
- (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success;
@end

View File

@ -0,0 +1,47 @@
//
// OAServiceTicket.m
// OAuthConsumer
//
// Created by Jon Crosby on 11/5/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OAServiceTicket.h"
@implementation OAServiceTicket
- (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success {
if (self = [super init]) {
self.request = aRequest;
self.response = aResponse;
self.didSucceed = success;
}
return self;
}
- (void)dealloc {
[self setRequest:nil];
[self setResponse:nil];
[super dealloc];
}
@end

View File

@ -0,0 +1,48 @@
//
// OAToken.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface OAToken : NSObject
@property (nonatomic, retain) NSString *verifier;
@property (nonatomic, retain) NSString *key;
@property (nonatomic, retain) NSString *secret;
- (NSString *)pin;
- (void)setPin:(NSString *)aPin;
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
- (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
- (id)initWithHTTPResponseBody:(NSString *)body;
+ (OAToken *)token;
+ (OAToken *)tokenWithKey:(NSString *)aKey secret:(NSString *)aSecret;
+ (OAToken *)tokenWithHTTPResponseBody:(NSString *)body;
+ (OAToken *)tokenWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
- (void)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
@end

View File

@ -0,0 +1,129 @@
//
// OAToken.m
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "OAToken.h"
@implementation OAToken
+ (OAToken *)token {
return [[[[self class]alloc]init]autorelease];
}
+ (OAToken *)tokenWithKey:(NSString *)aKey secret:(NSString *)aSecret {
return [[[[self class]alloc]initWithKey:aKey secret:aSecret]autorelease];
}
+ (OAToken *)tokenWithHTTPResponseBody:(NSString *)body {
return [[[[self class]alloc]initWithHTTPResponseBody:body]autorelease];
}
+ (OAToken *)tokenWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
return [[[[self class]alloc]initWithUserDefaultsUsingServiceProviderName:provider prefix:prefix]autorelease];
}
- (NSString *)pin {
return self.verifier;
}
- (void)setPin:(NSString *)aPin {
[self setVerifier:aPin];
}
- (id)init {
if (self = [super init]) {
self.key = @"";
self.secret = @"";
self.verifier = @"";
}
return self;
}
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret {
if (self = [super init]) {
self.key = aKey;
self.secret = aSecret;
self.verifier = @"";
}
return self;
}
- (id)initWithHTTPResponseBody:(NSString *)body {
if (self = [super init]) {
if (body == nil) {
body = @"";
}
NSArray *pairs = [body componentsSeparatedByString:@"&"];
for (NSString *pair in pairs) {
NSArray *elements = [pair componentsSeparatedByString:@"="];
if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token"]) {
self.key = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
} else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_secret"]) {
self.secret = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
}
self.verifier = @"";
}
return self;
}
- (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
self = [super init];
if (self) {
NSString *theKey = [[NSUserDefaults standardUserDefaults]stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
NSString *theSecret = [[NSUserDefaults standardUserDefaults]stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
BOOL nokey = (theKey.length == 0);
BOOL nosecret = (theSecret.length == 0);
if ((nokey && nosecret) || (nokey || nosecret)) {
return nil;
}
self.key = theKey;
self.secret = theSecret;
self.verifier = @"";
}
return self;
}
- (void)dealloc {
[self setVerifier:nil];
[self setKey:nil];
[self setSecret:nil];
[super dealloc];
}
- (void)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
[[NSUserDefaults standardUserDefaults]setObject:self.key forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
[[NSUserDefaults standardUserDefaults]setObject:self.secret forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
[[NSUserDefaults standardUserDefaults]synchronize];
}
@end

View File

@ -0,0 +1,37 @@
//
// OAuthConsumer.h
// OAuthConsumer
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// 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.
//
// FHSTwitterEngine OAuthConsumer Version 1.2.2
// As modified by Nate Symer (@natesymer)
//
#import <Foundation/Foundation.h>
#import "OAToken.h"
#import "OAConsumer.h"
#import "OAMutableURLRequest.h"
#import "OARequestParameter.h"
#import "OAServiceTicket.h"

View File

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

View File

@ -0,0 +1,319 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
FACAD88C1762C1B500D75ADE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD88B1762C1B500D75ADE /* Foundation.framework */; };
FACAD89F1762C22300D75ADE /* SocialTwitter.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD89E1762C22300D75ADE /* SocialTwitter.m */; };
FACAD8BA1762C61A00D75ADE /* FHSTwitterEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */; };
FACAD8BB1762C61A00D75ADE /* NSString+URLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */; };
FACAD8BC1762C61A00D75ADE /* Base64TranscoderFHS.c in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */; };
FACAD8BD1762C61A00D75ADE /* OAConsumer.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8AE1762C61A00D75ADE /* OAConsumer.m */; };
FACAD8BE1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */; };
FACAD8BF1762C61A00D75ADE /* OAMutableURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */; };
FACAD8C01762C61A00D75ADE /* OARequestParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B41762C61A00D75ADE /* OARequestParameter.m */; };
FACAD8C11762C61A00D75ADE /* OAServiceTicket.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */; };
FACAD8C21762C61A00D75ADE /* OAToken.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B81762C61A00D75ADE /* OAToken.m */; };
FACAD8C41762C64100D75ADE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8C31762C64100D75ADE /* UIKit.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
FACAD8861762C1B500D75ADE /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/${PRODUCT_NAME}";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
FACAD8881762C1B500D75ADE /* libPluginTwitter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginTwitter.a; sourceTree = BUILT_PRODUCTS_DIR; };
FACAD88B1762C1B500D75ADE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
FACAD89D1762C22300D75ADE /* SocialTwitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialTwitter.h; sourceTree = "<group>"; };
FACAD89E1762C22300D75ADE /* SocialTwitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialTwitter.m; sourceTree = "<group>"; };
FACAD8A41762C61A00D75ADE /* FHSTwitterEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHSTwitterEngine.h; sourceTree = "<group>"; };
FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FHSTwitterEngine.m; sourceTree = "<group>"; };
FACAD8A81762C61A00D75ADE /* NSString+URLEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+URLEncoding.h"; sourceTree = "<group>"; };
FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+URLEncoding.m"; sourceTree = "<group>"; };
FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Base64TranscoderFHS.c; sourceTree = "<group>"; };
FACAD8AC1762C61A00D75ADE /* Base64TranscoderFHS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64TranscoderFHS.h; sourceTree = "<group>"; };
FACAD8AD1762C61A00D75ADE /* OAConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAConsumer.h; sourceTree = "<group>"; };
FACAD8AE1762C61A00D75ADE /* OAConsumer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAConsumer.m; sourceTree = "<group>"; };
FACAD8AF1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAHMAC_SHA1SignatureProvider.h; sourceTree = "<group>"; };
FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAHMAC_SHA1SignatureProvider.m; sourceTree = "<group>"; };
FACAD8B11762C61A00D75ADE /* OAMutableURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAMutableURLRequest.h; sourceTree = "<group>"; };
FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAMutableURLRequest.m; sourceTree = "<group>"; };
FACAD8B31762C61A00D75ADE /* OARequestParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OARequestParameter.h; sourceTree = "<group>"; };
FACAD8B41762C61A00D75ADE /* OARequestParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OARequestParameter.m; sourceTree = "<group>"; };
FACAD8B51762C61A00D75ADE /* OAServiceTicket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAServiceTicket.h; sourceTree = "<group>"; };
FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAServiceTicket.m; sourceTree = "<group>"; };
FACAD8B71762C61A00D75ADE /* OAToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAToken.h; sourceTree = "<group>"; };
FACAD8B81762C61A00D75ADE /* OAToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAToken.m; sourceTree = "<group>"; };
FACAD8B91762C61A00D75ADE /* OAuthConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuthConsumer.h; sourceTree = "<group>"; };
FACAD8C31762C64100D75ADE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
FACAD8CB1762C76800D75ADE /* PluginTwitter-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginTwitter-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FACAD8851762C1B500D75ADE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FACAD8C41762C64100D75ADE /* UIKit.framework in Frameworks */,
FACAD88C1762C1B500D75ADE /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FACAD87D1762C1B500D75ADE = {
isa = PBXGroup;
children = (
FACAD8CB1762C76800D75ADE /* PluginTwitter-Prefix.pch */,
FACAD8A31762C61A00D75ADE /* FHSTwitterEngine */,
FACAD89D1762C22300D75ADE /* SocialTwitter.h */,
FACAD89E1762C22300D75ADE /* SocialTwitter.m */,
FACAD88A1762C1B500D75ADE /* Frameworks */,
FACAD8891762C1B500D75ADE /* Products */,
);
sourceTree = "<group>";
};
FACAD8891762C1B500D75ADE /* Products */ = {
isa = PBXGroup;
children = (
FACAD8881762C1B500D75ADE /* libPluginTwitter.a */,
);
name = Products;
sourceTree = "<group>";
};
FACAD88A1762C1B500D75ADE /* Frameworks */ = {
isa = PBXGroup;
children = (
FACAD8C31762C64100D75ADE /* UIKit.framework */,
FACAD88B1762C1B500D75ADE /* Foundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
FACAD8A31762C61A00D75ADE /* FHSTwitterEngine */ = {
isa = PBXGroup;
children = (
FACAD8A41762C61A00D75ADE /* FHSTwitterEngine.h */,
FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */,
FACAD8A61762C61A00D75ADE /* OAuthConsumer */,
);
path = FHSTwitterEngine;
sourceTree = "<group>";
};
FACAD8A61762C61A00D75ADE /* OAuthConsumer */ = {
isa = PBXGroup;
children = (
FACAD8A71762C61A00D75ADE /* Categories */,
FACAD8AA1762C61A00D75ADE /* Crytpo */,
FACAD8AD1762C61A00D75ADE /* OAConsumer.h */,
FACAD8AE1762C61A00D75ADE /* OAConsumer.m */,
FACAD8AF1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.h */,
FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */,
FACAD8B11762C61A00D75ADE /* OAMutableURLRequest.h */,
FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */,
FACAD8B31762C61A00D75ADE /* OARequestParameter.h */,
FACAD8B41762C61A00D75ADE /* OARequestParameter.m */,
FACAD8B51762C61A00D75ADE /* OAServiceTicket.h */,
FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */,
FACAD8B71762C61A00D75ADE /* OAToken.h */,
FACAD8B81762C61A00D75ADE /* OAToken.m */,
FACAD8B91762C61A00D75ADE /* OAuthConsumer.h */,
);
path = OAuthConsumer;
sourceTree = "<group>";
};
FACAD8A71762C61A00D75ADE /* Categories */ = {
isa = PBXGroup;
children = (
FACAD8A81762C61A00D75ADE /* NSString+URLEncoding.h */,
FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */,
);
path = Categories;
sourceTree = "<group>";
};
FACAD8AA1762C61A00D75ADE /* Crytpo */ = {
isa = PBXGroup;
children = (
FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */,
FACAD8AC1762C61A00D75ADE /* Base64TranscoderFHS.h */,
);
path = Crytpo;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FACAD8871762C1B500D75ADE /* PluginTwitter */ = {
isa = PBXNativeTarget;
buildConfigurationList = FACAD8961762C1B500D75ADE /* Build configuration list for PBXNativeTarget "PluginTwitter" */;
buildPhases = (
FACAD8841762C1B500D75ADE /* Sources */,
FACAD8851762C1B500D75ADE /* Frameworks */,
FACAD8861762C1B500D75ADE /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = PluginTwitter;
productName = PluginTwitter;
productReference = FACAD8881762C1B500D75ADE /* libPluginTwitter.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FACAD87F1762C1B500D75ADE /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
ORGANIZATIONNAME = zhangbin;
};
buildConfigurationList = FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = FACAD87D1762C1B500D75ADE;
productRefGroup = FACAD8891762C1B500D75ADE /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FACAD8871762C1B500D75ADE /* PluginTwitter */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
FACAD8841762C1B500D75ADE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FACAD89F1762C22300D75ADE /* SocialTwitter.m in Sources */,
FACAD8BA1762C61A00D75ADE /* FHSTwitterEngine.m in Sources */,
FACAD8BB1762C61A00D75ADE /* NSString+URLEncoding.m in Sources */,
FACAD8BC1762C61A00D75ADE /* Base64TranscoderFHS.c in Sources */,
FACAD8BD1762C61A00D75ADE /* OAConsumer.m in Sources */,
FACAD8BE1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m in Sources */,
FACAD8BF1762C61A00D75ADE /* OAMutableURLRequest.m in Sources */,
FACAD8C01762C61A00D75ADE /* OARequestParameter.m in Sources */,
FACAD8C11762C61A00D75ADE /* OAServiceTicket.m in Sources */,
FACAD8C21762C61A00D75ADE /* OAToken.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
FACAD8941762C1B500D75ADE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
SDKROOT = iphoneos;
};
name = Debug;
};
FACAD8951762C1B500D75ADE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FACAD8971762C1B500D75ADE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginTwitter.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
FACAD8981762C1B500D75ADE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginTwitter.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FACAD8941762C1B500D75ADE /* Debug */,
FACAD8951762C1B500D75ADE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FACAD8961762C1B500D75ADE /* Build configuration list for PBXNativeTarget "PluginTwitter" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FACAD8971762C1B500D75ADE /* Debug */,
FACAD8981762C1B500D75ADE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FACAD87F1762C1B500D75ADE /* Project object */;
}

View File

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

View File

@ -0,0 +1,142 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "SocialTwitter.h"
#import "FHSTwitterEngine.h"
#import "SocialWrapper.h"
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
@implementation SocialTwitter
@synthesize mShareInfo;
@synthesize debug = __debug;
- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo
{
NSString* appKey = [cpInfo objectForKey:@"TwitterKey"];
NSString* appSecret = [cpInfo objectForKey:@"TwitterSecret"];
if (nil == appKey || nil == appSecret) {
return;
}
[[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:appKey andSecret:appSecret];
}
- (void) share: (NSMutableDictionary*) shareInfo
{
self.mShareInfo = shareInfo;
if ([[FHSTwitterEngine sharedEngine]isAuthorized])
{
[self doShare];
} else {
UIViewController* controller = [self getCurrentRootViewController];
[[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:controller withCompletion:^(BOOL success) {
if (success) {
[self doShare];
} else {
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:@"Login Failed"];
}
}];
}
}
- (void) setDebugMode: (BOOL) debug
{
self.debug = debug;
}
- (NSString*) getSDKVersion
{
return @"20130607";
}
- (NSString*) getPluginVersion
{
return @"0.2.0";
}
- (void) doShare
{
if (nil == mShareInfo) {
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:@"Shared info error"];
return;
}
NSString* strText = [mShareInfo objectForKey:@"SharedText"];
NSString* strImagePath = [mShareInfo objectForKey:@"SharedImagePath"];
BOOL oldConfig = [UIApplication sharedApplication].networkActivityIndicatorVisible;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSError* returnCode = nil;
if (nil != strImagePath) {
NSData* data = [NSData dataWithContentsOfFile:strImagePath];
returnCode = [[FHSTwitterEngine sharedEngine] postTweet:strText withImageData:data];
} else {
returnCode = [[FHSTwitterEngine sharedEngine]postTweet:strText];
}
[UIApplication sharedApplication].networkActivityIndicatorVisible = oldConfig;
if (returnCode) {
NSString* strErrorCode = [NSString stringWithFormat:@"ErrorCode %d", returnCode.code];
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:strErrorCode];
} else {
[SocialWrapper onShareResult:self withRet:kShareSuccess withMsg:@"Share Succeed"];
}
}
- (UIViewController *)getCurrentRootViewController {
UIViewController *result = nil;
// Try to find the root view controller programmically
// Find the top window (that is not an alert view or other window)
UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];
if (topWindow.windowLevel != UIWindowLevelNormal)
{
NSArray *windows = [[UIApplication sharedApplication] windows];
for(topWindow in windows)
{
if (topWindow.windowLevel == UIWindowLevelNormal)
break;
}
}
UIView *rootView = [[topWindow subviews] objectAtIndex:0];
id nextResponder = [rootView nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]])
result = nextResponder;
else if ([topWindow respondsToSelector:@selector(rootViewController)] && topWindow.rootViewController != nil)
result = topWindow.rootViewController;
else
NSAssert(NO, @"Could not find a root view controller.");
return result;
}
@end

View File

@ -185,10 +185,7 @@
DSTROOT = /tmp/libPluginUmeng.dst; DSTROOT = /tmp/libPluginUmeng.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)\"", "\"$(SRCROOT)\"",
@ -207,10 +204,7 @@
DSTROOT = /tmp/libPluginUmeng.dst; DSTROOT = /tmp/libPluginUmeng.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)\"", "\"$(SRCROOT)\"",

View File

@ -225,14 +225,12 @@
FAE2753F175D9D2B00F5DA8E /* Debug */ = { FAE2753F175D9D2B00F5DA8E /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginWeibo.dst; DSTROOT = /tmp/PluginWeibo.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -242,14 +240,12 @@
FAE27540175D9D2B00F5DA8E /* Release */ = { FAE27540175D9D2B00F5DA8E /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginWeibo.dst; DSTROOT = /tmp/PluginWeibo.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
"$(SRCROOT)/../../../protocols/include",
"$(SRCROOT)/../../../protocols/platform/ios",
);
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;

View File

@ -80,7 +80,7 @@ PluginProtocol* PluginManager::loadPlugin(const char* name)
} else } else
{ {
pRet = PluginFactory::getInstance()->createPlugin(name); pRet = PluginFactory::getInstance()->createPlugin(name);
m_pluginsMap["name"] = pRet; m_pluginsMap[name] = pRet;
} }
} while (false); } while (false);

View File

@ -40,12 +40,25 @@ if (PluginJniHelper::getMethodInfo(t \
, funcName \ , funcName \
, paramCode)) \ , paramCode)) \
{ \ { \
if (NULL != param) \ ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \
{ \ t.env->DeleteLocalRef(t.classID); \
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \ } \
} else { \ return ret; \
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \
} \
#define CALL_BASERET_JAVA_FUNC(retType, paramCode, retCode, defaultRet) \
retType ret = defaultRet; \
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); \
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); \
return_val_if_fails(pData != NULL, ret); \
\
PluginJniMethodInfo t; \
if (PluginJniHelper::getMethodInfo(t \
, pData->jclassName.c_str() \
, funcName \
, paramCode)) \
{ \
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \
t.env->DeleteLocalRef(t.classID); \ t.env->DeleteLocalRef(t.classID); \
} \ } \
return ret; \ return ret; \
@ -88,7 +101,7 @@ if (0 == nParamNum)
{ \ { \
paramCode = "()"; \ paramCode = "()"; \
paramCode.append(jRetCode); \ paramCode.append(jRetCode); \
ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), NULL); \ ret = PluginUtils::callJava##retCode##FuncWithName(this, funcName); \
} else \ } else \
{ \ { \
PluginParam* pRetParam = NULL; \ PluginParam* pRetParam = NULL; \

View File

@ -107,7 +107,7 @@ void PluginProtocol::callFuncWithParam(const char* funcName, std::vector<PluginP
int nParamNum = params.size(); int nParamNum = params.size();
if (nParamNum == 0) if (nParamNum == 0)
{ {
PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "()V", NULL); PluginUtils::callJavaFunctionWithName(this, funcName);
} else } else
{ {
PluginParam* pRetParam = NULL; PluginParam* pRetParam = NULL;

View File

@ -63,12 +63,23 @@ public:
, funcName , funcName
, paramCode)) , paramCode))
{ {
if (param != NULL) t.env->CallVoidMethod(pData->jobj, t.methodID, param);
{ t.env->DeleteLocalRef(t.classID);
t.env->CallVoidMethod(pData->jobj, t.methodID, param); }
} else { }
t.env->CallVoidMethod(pData->jobj, t.methodID); static void callJavaFunctionWithName(PluginProtocol* thiz, const char* funcName)
} {
return_if_fails(funcName != NULL && strlen(funcName) > 0);
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz);
return_if_fails(pData != NULL);
PluginJniMethodInfo t;
if (PluginJniHelper::getMethodInfo(t
, pData->jclassName.c_str()
, funcName
, "()V"))
{
t.env->CallVoidMethod(pData->jobj, t.methodID);
t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(t.classID);
} }
} }
@ -101,6 +112,25 @@ public:
} }
return ret; return ret;
} }
static const char* callJavaStringFuncWithName(PluginProtocol* thiz, const char* funcName)
{
const char* ret = "";
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz);
return_val_if_fails(pData != NULL, ret);
PluginJniMethodInfo t;
if (PluginJniHelper::getMethodInfo(t
, pData->jclassName.c_str()
, funcName
, "()Ljava/lang/String;"))
{
jstring strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID);
ret = PluginJniHelper::jstring2string(strRet).c_str();
t.env->DeleteLocalRef(t.classID);
}
return ret;
}
// methods return value is int // methods return value is int
template <typename T> template <typename T>
@ -108,6 +138,10 @@ public:
{ {
CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0) CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0)
} }
static int callJavaIntFuncWithName(PluginProtocol* thiz, const char* funcName)
{
CALL_BASERET_JAVA_FUNC(int, "()I", Int, 0)
}
// methods return value is float // methods return value is float
template <typename T> template <typename T>
@ -115,6 +149,10 @@ public:
{ {
CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f) CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f)
} }
static float callJavaFloatFuncWithName(PluginProtocol* thiz, const char* funcName)
{
CALL_BASERET_JAVA_FUNC(float, "()F", Float, 0.0f);
}
// methods return value is bool // methods return value is bool
template <typename T> template <typename T>
@ -122,6 +160,10 @@ public:
{ {
CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false) CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false)
} }
static bool callJavaBoolFuncWithName(PluginProtocol* thiz, const char* funcName)
{
CALL_BASERET_JAVA_FUNC(bool, "()Z", Boolean, false)
}
static void outputLog(const char* logTag, const char* pFormat, ...); static void outputLog(const char* logTag, const char* pFormat, ...);
}; };

View File

@ -61,7 +61,7 @@ if (NULL == pData) {
int nParamNum = params.size(); \ int nParamNum = params.size(); \
if (0 == nParamNum) \ if (0 == nParamNum) \
{ \ { \
ret = PluginUtilsIOS::callOC##retCode##FunctionWithName_oneParam(this, funcName, NULL); \ ret = PluginUtilsIOS::callOC##retCode##FunctionWithName(this, funcName); \
} else \ } else \
{ \ { \
PluginParam* pRetParam = NULL; \ PluginParam* pRetParam = NULL; \

View File

@ -117,7 +117,7 @@ void PluginProtocol::callFuncWithParam(const char* funcName, std::vector<PluginP
int nParamNum = params.size(); int nParamNum = params.size();
if (0 == nParamNum) if (0 == nParamNum)
{ {
PluginUtilsIOS::callOCFunctionWithName_oneParam(this, funcName, NULL); PluginUtilsIOS::callOCFunctionWithName(this, funcName);
} else } else
{ {
PluginParam* pRetParam = NULL; PluginParam* pRetParam = NULL;

View File

@ -57,31 +57,37 @@ public:
@brief method don't have return value @brief method don't have return value
*/ */
static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
static void callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
/** /**
@brief method return int value @brief method return int value
*/ */
static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
static int callOCIntFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
/** /**
@brief method return float value @brief method return float value
*/ */
static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
static float callOCFloatFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
/** /**
@brief method return bool value @brief method return bool value
*/ */
static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
static bool callOCBoolFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
/** /**
@brief method return string value @brief method return string value
*/ */
static const char* callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param); static const char* callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
static const char* callOCStringFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
static void outputLog(const char* pFormat, ...); static void outputLog(const char* pFormat, ...);
private: private:
static id callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param); static id callRetFunctionWithParam(PluginProtocol* pPlugin, const char* funcName, id param);
static id callRetFunction(PluginProtocol* pPlugin, const char* funcName);
}; };
}} // namespace cocos2d { namespace plugin { }} // namespace cocos2d { namespace plugin {

View File

@ -172,16 +172,31 @@ void PluginUtilsIOS::callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, co
id pOCObj = pData->obj; id pOCObj = pData->obj;
NSString* strFuncName = [NSString stringWithUTF8String:funcName]; NSString* strFuncName = [NSString stringWithUTF8String:funcName];
if (param != nil) { strFuncName = [strFuncName stringByAppendingString:@":"];
strFuncName = [strFuncName stringByAppendingString:@":"];
}
SEL selector = NSSelectorFromString(strFuncName); SEL selector = NSSelectorFromString(strFuncName);
if ([pOCObj respondsToSelector:selector]) { if ([pOCObj respondsToSelector:selector]) {
if (param == nil) { [pOCObj performSelector:selector withObject:param];
[pOCObj performSelector:selector]; } else {
} else { outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
[pOCObj performSelector:selector withObject:param]; }
} } else {
PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName());
}
}
void PluginUtilsIOS::callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
{
return_if_fails(funcName != NULL && strlen(funcName) > 0);
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
if (pData) {
id pOCObj = pData->obj;
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
SEL selector = NSSelectorFromString(strFuncName);
if ([pOCObj respondsToSelector:selector]) {
[pOCObj performSelector:selector];
} else { } else {
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str()); outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
} }
@ -192,14 +207,33 @@ void PluginUtilsIOS::callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, co
int PluginUtilsIOS::callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) int PluginUtilsIOS::callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
{ {
int ret = (NSInteger)callRetFunction(pPlugin, funcName, param); NSNumber* num = (NSNumber*) callRetFunctionWithParam(pPlugin, funcName, param);
int ret = [num integerValue];
return ret;
}
int PluginUtilsIOS::callOCIntFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
{
NSNumber* num = (NSNumber*) callRetFunction(pPlugin, funcName);
int ret = [num integerValue];
return ret; return ret;
} }
float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
{ {
float ret = 0.0f; float ret = 0.0f;
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param); NSNumber* pRet = (NSNumber*)callRetFunctionWithParam(pPlugin, funcName, param);
if (nil != pRet) {
ret = [pRet floatValue];
}
return ret;
}
float PluginUtilsIOS::callOCFloatFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
{
float ret = 0.0f;
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName);
if (nil != pRet) { if (nil != pRet) {
ret = [pRet floatValue]; ret = [pRet floatValue];
} }
@ -210,7 +244,18 @@ float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlug
bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
{ {
bool ret = false; bool ret = false;
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param); NSNumber* pRet = (NSNumber*)callRetFunctionWithParam(pPlugin, funcName, param);
if (nil != pRet) {
ret = [pRet boolValue];
}
return ret;
}
bool PluginUtilsIOS::callOCBoolFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
{
bool ret = false;
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName);
if (nil != pRet) { if (nil != pRet) {
ret = [pRet boolValue]; ret = [pRet boolValue];
} }
@ -221,7 +266,7 @@ bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin
const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param) const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
{ {
const char* ret = ""; const char* ret = "";
NSString* pRet = (NSString*)callRetFunction(pPlugin, funcName, param); NSString* pRet = (NSString*)callRetFunctionWithParam(pPlugin, funcName, param);
if (nil != pRet) { if (nil != pRet) {
ret = [pRet UTF8String]; ret = [pRet UTF8String];
} }
@ -229,7 +274,18 @@ const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol
return ret; return ret;
} }
id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param) const char* PluginUtilsIOS::callOCStringFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
{
const char* ret = "";
NSString* pRet = (NSString*)callRetFunction(pPlugin, funcName);
if (nil != pRet) {
ret = [pRet UTF8String];
}
return ret;
}
id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName)
{ {
id ret = nil; id ret = nil;
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
@ -239,16 +295,33 @@ id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName
id pOCObj = pData->obj; id pOCObj = pData->obj;
NSString* strFuncName = [NSString stringWithUTF8String:funcName]; NSString* strFuncName = [NSString stringWithUTF8String:funcName];
if (param != nil) {
strFuncName = [strFuncName stringByAppendingString:@":"];
}
SEL selector = NSSelectorFromString(strFuncName); SEL selector = NSSelectorFromString(strFuncName);
if ([pOCObj respondsToSelector:selector]) { if ([pOCObj respondsToSelector:selector]) {
if (param == nil) { ret = [pOCObj performSelector:selector];
ret = [pOCObj performSelector:selector]; } else {
} else { outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
ret = [pOCObj performSelector:selector withObject:param]; }
} } else {
PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName());
}
return ret;
}
id PluginUtilsIOS::callRetFunctionWithParam(PluginProtocol* pPlugin, const char* funcName, id param)
{
id ret = nil;
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
if (pData) {
id pOCObj = pData->obj;
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
strFuncName = [strFuncName stringByAppendingString:@":"];
SEL selector = NSSelectorFromString(strFuncName);
if ([pOCObj respondsToSelector:selector]) {
ret = [pOCObj performSelector:selector withObject:param];
} else { } else {
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str()); outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
} }

View File

@ -171,7 +171,7 @@
FA09A318168ADBC2008C1C7B /* Project object */ = { FA09A318168ADBC2008C1C7B /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin; ORGANIZATIONNAME = zhangbin;
}; };
buildConfigurationList = FA09A31B168ADBC2008C1C7B /* Build configuration list for PBXProject "PluginProtocol" */; buildConfigurationList = FA09A31B168ADBC2008C1C7B /* Build configuration list for PBXProject "PluginProtocol" */;
@ -219,6 +219,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -245,6 +248,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;

View File

@ -35,6 +35,8 @@
D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949B15BD2D8E00D803EB /* Icon-114.png */; }; D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949B15BD2D8E00D803EB /* Icon-114.png */; };
D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949D15BD2D9600D803EB /* Icon-72.png */; }; D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949D15BD2D9600D803EB /* Icon-72.png */; };
D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949F15BD2D9800D803EB /* Icon-144.png */; }; D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949F15BD2D9800D803EB /* Icon-144.png */; };
FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */; };
FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */; };
FAE27583175DEC8600F5DA8E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27580175DEC8600F5DA8E /* background.png */; }; FAE27583175DEC8600F5DA8E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27580175DEC8600F5DA8E /* background.png */; };
FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAE27581175DEC8600F5DA8E /* twitter.jpeg */; }; FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAE27581175DEC8600F5DA8E /* twitter.jpeg */; };
FAE27585175DEC8600F5DA8E /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27582175DEC8600F5DA8E /* weibo.png */; }; FAE27585175DEC8600F5DA8E /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27582175DEC8600F5DA8E /* weibo.png */; };
@ -46,6 +48,13 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FACAD8881762C1B500D75ADE;
remoteInfo = PluginTwitter;
};
FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */ = { FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */; containerPortal = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */;
@ -112,6 +121,8 @@
D4EF949D15BD2D9600D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = "<group>"; }; D4EF949D15BD2D9600D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = "<group>"; };
D4EF949F15BD2D9800D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = "<group>"; }; D4EF949F15BD2D9800D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = "<group>"; };
D4F9F37B12E54555005CA6D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; D4F9F37B12E54555005CA6D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginTwitter.xcodeproj; path = ../../../plugins/twitter/proj.ios/PluginTwitter.xcodeproj; sourceTree = "<group>"; };
FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; }; FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
FAE27580175DEC8600F5DA8E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; }; FAE27580175DEC8600F5DA8E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
FAE27581175DEC8600F5DA8E /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; }; FAE27581175DEC8600F5DA8E /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; };
@ -128,6 +139,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */,
FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */,
FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */, FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */,
FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */, FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */,
FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */, FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */,
@ -223,6 +236,8 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */,
FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */,
FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */, FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */,
FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */, FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */,
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */, FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */,
@ -273,6 +288,14 @@
path = ../Resources; path = ../Resources;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
FACAD8EE1762DC3A00D75ADE /* Products */ = {
isa = PBXGroup;
children = (
FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */,
);
name = Products;
sourceTree = "<group>";
};
FAE27578175DEC0C00F5DA8E /* Products */ = { FAE27578175DEC0C00F5DA8E /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -346,6 +369,10 @@
ProductGroup = FAE27587175DED1700F5DA8E /* Products */; ProductGroup = FAE27587175DED1700F5DA8E /* Products */;
ProjectRef = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */; ProjectRef = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */;
}, },
{
ProductGroup = FACAD8EE1762DC3A00D75ADE /* Products */;
ProjectRef = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */;
},
{ {
ProductGroup = FAE27590175DED2300F5DA8E /* Products */; ProductGroup = FAE27590175DED2300F5DA8E /* Products */;
ProjectRef = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */; ProjectRef = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */;
@ -359,6 +386,13 @@
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXReferenceProxy section */ /* Begin PBXReferenceProxy section */
FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libPluginTwitter.a;
remoteRef = FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */ = { FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */ = {
isa = PBXReferenceProxy; isa = PBXReferenceProxy;
fileType = archive.ar; fileType = archive.ar;
@ -430,8 +464,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CLANG_CXX_LIBRARY = "libc++";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
@ -457,13 +491,13 @@
"\"$(SRCROOT)/../../../protocols/include", "\"$(SRCROOT)/../../../protocols/include",
); );
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 4.0; IPHONEOS_DEPLOYMENT_TARGET = 5.1;
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\""; LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
OTHER_CFLAGS = "-O2"; OTHER_CFLAGS = "-O2";
"OTHER_LDFLAGS[arch=*]" = "-ObjC"; "OTHER_LDFLAGS[arch=*]" = "-ObjC";
PRODUCT_NAME = HelloSocial; PRODUCT_NAME = HelloSocial;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "34B6E084-2760-4B9B-94CE-0998083C95F5";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "34B6E084-2760-4B9B-94CE-0998083C95F5";
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "";
@ -475,8 +509,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CLANG_CXX_LIBRARY = "libc++";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -500,12 +534,12 @@
"\"$(SRCROOT)/../../../protocols/include", "\"$(SRCROOT)/../../../protocols/include",
); );
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 4.0; IPHONEOS_DEPLOYMENT_TARGET = 5.1;
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\""; LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
"OTHER_LDFLAGS[arch=*]" = "-ObjC"; "OTHER_LDFLAGS[arch=*]" = "-ObjC";
PRODUCT_NAME = HelloSocial; PRODUCT_NAME = HelloSocial;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "34B6E084-2760-4B9B-94CE-0998083C95F5";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "34B6E084-2760-4B9B-94CE-0998083C95F5";
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "";
@ -517,12 +551,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PROVISIONING_PROFILE = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALID_ARCHS = "armv6 armv7 i386"; VALID_ARCHS = "armv6 armv7 i386";
}; };
@ -532,13 +566,13 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
GCC_C_LANGUAGE_STANDARD = c99; GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = ""; GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PROVISIONING_PROFILE = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "DB6844BA-2943-44DB-B10A-3A3F0E8A52B8";
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALID_ARCHS = "armv6 armv7 i386"; VALID_ARCHS = "armv6 armv7 i386";
}; };

View File

@ -25,12 +25,12 @@
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/proj.tizen/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/> <builder autoBuildTarget="all" buildPath="${workspace_loc:/proj.tizen/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/> <tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
</option> </option>
<option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -50,7 +50,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIE"/> <listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -58,14 +57,15 @@
<listOptionValue builtIn="false" value="_DEBUG"/> <listOptionValue builtIn="false" value="_DEBUG"/>
<listOptionValue builtIn="false" value="TIZEN"/> <listOptionValue builtIn="false" value="TIZEN"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.434981835" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/> <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
</tool> </tool>
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler"> <tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> <option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -85,7 +85,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIE"/> <listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -96,7 +95,7 @@
<inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/> <inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
</tool> </tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
<option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/proj.tizen/Debug-Tizen-Emulator&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/proj.tizen/Debug-Tizen-Emulator&quot;"/>
@ -105,7 +104,7 @@
<listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/platform/third_party/tizen/prebuilt/libwebp/libs/x86&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/platform/third_party/tizen/prebuilt/libwebp/libs/x86&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/> <listOptionValue builtIn="false" value="-Xlinker --as-needed"/>
<listOptionValue builtIn="false" value="-pie -lpthread "/> <listOptionValue builtIn="false" value="-pie -lpthread "/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/opt/usr/apps/chzfHkPFS6/lib&quot;"/> <listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/opt/usr/apps/chzfHkPFS6/lib&quot;"/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/> <listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/>

View File

@ -25,12 +25,12 @@
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/SimpleGame/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/> <builder autoBuildTarget="all" buildPath="${workspace_loc:/SimpleGame/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/> <tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
<tool command="clang++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler"> <tool command="i386-linux-gnueabi-g++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs"> <option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
</option> </option>
<option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -54,7 +54,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIE"/> <listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -62,14 +61,15 @@
<listOptionValue builtIn="false" value="_DEBUG"/> <listOptionValue builtIn="false" value="_DEBUG"/>
<listOptionValue builtIn="false" value="TIZEN"/> <listOptionValue builtIn="false" value="TIZEN"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.1216683783" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/> <inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
</tool> </tool>
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler"> <tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/> <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> <option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/> <option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs"> <option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/> <listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
</option> </option>
<option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
@ -88,7 +88,6 @@
<listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/> <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/osp&quot;"/>
</option> </option>
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList"> <option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
<listOptionValue builtIn="false" value=" -fPIE"/> <listOptionValue builtIn="false" value=" -fPIE"/>
<listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/> <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
</option> </option>
@ -99,7 +98,7 @@
<inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/> <inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
</tool> </tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker"> <tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
<option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/> <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/platform/third_party/tizen/rootstraps/tizen-emulator-2.1.native/lib&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_SRC}/platform/third_party/tizen/rootstraps/tizen-emulator-2.1.native/lib&quot;"/>
@ -109,7 +108,7 @@
<listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/CocosDenshion/proj.tizen/Debug-Tizen-Emulator&quot;"/> <listOptionValue builtIn="false" value="&quot;${COCOS_ROOT}/CocosDenshion/proj.tizen/Debug-Tizen-Emulator&quot;"/>
</option> </option>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList"> <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain &quot;C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/&quot; -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/> <listOptionValue builtIn="false" value="-Xlinker --as-needed"/>
<listOptionValue builtIn="false" value="-pie -lpthread "/> <listOptionValue builtIn="false" value="-pie -lpthread "/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/opt/usr/apps/9SFk2uuXBH/lib&quot;"/> <listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/opt/usr/apps/9SFk2uuXBH/lib&quot;"/>
<listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/> <listOptionValue builtIn="false" value="-Xlinker -rpath=&quot;/home/developer/sdk_tools/lib&quot;"/>

View File

@ -100,6 +100,7 @@ Classes/ConfigurationTest/ConfigurationTest.cpp \
Classes/controller.cpp \ Classes/controller.cpp \
Classes/testBasic.cpp \ Classes/testBasic.cpp \
Classes/AppDelegate.cpp \ Classes/AppDelegate.cpp \
Classes/BaseTest.cpp \
Classes/VisibleRect.cpp Classes/VisibleRect.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static

View File

@ -82,28 +82,6 @@ std::string ActionManagerTest::title()
return "No title"; return "No title";
} }
void ActionManagerTest::onEnter()
{
CCLayer::onEnter();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label, 1);
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&ActionManagerTest::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&ActionManagerTest::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&ActionManagerTest::nextCallback, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
addChild(menu, 1);
}
void ActionManagerTest::restartCallback(CCObject* pSender) void ActionManagerTest::restartCallback(CCObject* pSender)
{ {
CCScene* s = new ActionManagerTestScene(); CCScene* s = new ActionManagerTestScene();

View File

@ -2,8 +2,9 @@
#define _ACTION_MANAGER_TEST_H_ #define _ACTION_MANAGER_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class ActionManagerTest: public CCLayer class ActionManagerTest: public BaseTest
{ {
protected: protected:
CCTextureAtlas* m_atlas; CCTextureAtlas* m_atlas;
@ -15,7 +16,6 @@ public:
~ActionManagerTest(void); ~ActionManagerTest(void);
virtual std::string title(); virtual std::string title();
virtual void onEnter();
void restartCallback(CCObject* pSender); void restartCallback(CCObject* pSender);
void nextCallback(CCObject* pSender); void nextCallback(CCObject* pSender);

View File

@ -606,7 +606,7 @@ std::string EaseSpriteDemo::title()
void EaseSpriteDemo::onEnter() void EaseSpriteDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too // Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain(); m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain();
@ -620,23 +620,6 @@ void EaseSpriteDemo::onEnter()
m_grossini->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5)); m_grossini->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5));
m_kathia->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5)); m_kathia->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5));
m_tamara->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); m_tamara->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5));
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&EaseSpriteDemo::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&EaseSpriteDemo::restartCallback , this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&EaseSpriteDemo::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
addChild(menu, 1);
} }
void EaseSpriteDemo::restartCallback(CCObject* pSender) void EaseSpriteDemo::restartCallback(CCObject* pSender)

View File

@ -3,10 +3,11 @@
////----#include "cocos2d.h" ////----#include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
USING_NS_CC; USING_NS_CC;
class EaseSpriteDemo : public CCLayer class EaseSpriteDemo : public BaseTest
{ {
protected: protected:
CCSprite* m_grossini; CCSprite* m_grossini;

View File

@ -90,32 +90,7 @@ std::string SpriteDemo::subtitle()
void SpriteDemo::onEnter() void SpriteDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22);
addChild(l, 1);
l->setPosition( ccp(s.width/2, s.height-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255)); CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255));
addChild(background, -10); addChild(background, -10);

View File

@ -2,8 +2,9 @@
#define _ACTIONS_PROGRESS_TEST_H_ #define _ACTIONS_PROGRESS_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class SpriteDemo : public CCLayer class SpriteDemo : public BaseTest
{ {
public: public:
SpriteDemo(void); SpriteDemo(void);

View File

@ -2,101 +2,53 @@
#include "../testResource.h" #include "../testResource.h"
#include "cocos2d.h" #include "cocos2d.h"
TESTLAYER_CREATE_FUNC(ActionManual); static std::function<CCLayer*()> createFunctions[] = {
TESTLAYER_CREATE_FUNC(ActionMove); CL(ActionManual),
TESTLAYER_CREATE_FUNC(ActionRotate); CL(ActionMove),
TESTLAYER_CREATE_FUNC(ActionScale); CL(ActionRotate),
TESTLAYER_CREATE_FUNC(ActionSkew); CL(ActionScale),
TESTLAYER_CREATE_FUNC(ActionRotationalSkew); CL(ActionSkew),
TESTLAYER_CREATE_FUNC(ActionRotationalSkewVSStandardSkew); CL(ActionRotationalSkew),
TESTLAYER_CREATE_FUNC(ActionSkewRotateScale); CL(ActionRotationalSkewVSStandardSkew),
TESTLAYER_CREATE_FUNC(ActionJump); CL(ActionSkewRotateScale),
TESTLAYER_CREATE_FUNC(ActionCardinalSpline); CL(ActionJump),
TESTLAYER_CREATE_FUNC(ActionCatmullRom); CL(ActionCardinalSpline),
TESTLAYER_CREATE_FUNC(ActionBezier); CL(ActionCatmullRom),
TESTLAYER_CREATE_FUNC(ActionBlink); CL(ActionBezier),
TESTLAYER_CREATE_FUNC(ActionFade); CL(ActionBlink),
TESTLAYER_CREATE_FUNC(ActionTint); CL(ActionFade),
TESTLAYER_CREATE_FUNC(ActionAnimate); CL(ActionTint),
TESTLAYER_CREATE_FUNC(ActionSequence); CL(ActionAnimate),
TESTLAYER_CREATE_FUNC(ActionSequence2); CL(ActionSequence),
TESTLAYER_CREATE_FUNC(ActionSpawn); CL(ActionSequence2),
TESTLAYER_CREATE_FUNC(ActionReverse); CL(ActionRemoveSelf),
TESTLAYER_CREATE_FUNC(ActionDelayTime); CL(ActionSpawn),
TESTLAYER_CREATE_FUNC(ActionRepeat); CL(ActionReverse),
TESTLAYER_CREATE_FUNC(ActionRepeatForever); CL(ActionDelayTime),
TESTLAYER_CREATE_FUNC(ActionRotateToRepeat); CL(ActionRepeat),
TESTLAYER_CREATE_FUNC(ActionRotateJerk); CL(ActionRepeatForever),
TESTLAYER_CREATE_FUNC(ActionCallFunction); CL(ActionRotateToRepeat),
TESTLAYER_CREATE_FUNC(ActionCallFunc); CL(ActionRotateJerk),
TESTLAYER_CREATE_FUNC(ActionCallFuncND); CL(ActionCallFunction),
TESTLAYER_CREATE_FUNC(ActionReverseSequence); CL(ActionCallFunc),
TESTLAYER_CREATE_FUNC(ActionReverseSequence2); CL(ActionCallFuncND),
TESTLAYER_CREATE_FUNC(ActionRemoveSelf); CL(ActionReverseSequence),
TESTLAYER_CREATE_FUNC(ActionOrbit); CL(ActionReverseSequence2),
TESTLAYER_CREATE_FUNC(ActionFollow); CL(ActionOrbit),
TESTLAYER_CREATE_FUNC(ActionTargeted); CL(ActionFollow),
TESTLAYER_CREATE_FUNC(ActionMoveStacked); CL(ActionTargeted),
TESTLAYER_CREATE_FUNC(ActionMoveJumpStacked); CL(ActionMoveStacked),
TESTLAYER_CREATE_FUNC(ActionMoveBezierStacked); CL(ActionMoveJumpStacked),
TESTLAYER_CREATE_FUNC(ActionCardinalSplineStacked); CL(ActionMoveBezierStacked),
TESTLAYER_CREATE_FUNC(ActionCatmullRomStacked); CL(ActionCardinalSplineStacked),
TESTLAYER_CREATE_FUNC(PauseResumeActions); CL(ActionCatmullRomStacked),
TESTLAYER_CREATE_FUNC(Issue1305); CL(PauseResumeActions),
TESTLAYER_CREATE_FUNC(Issue1305_2); CL(Issue1305),
TESTLAYER_CREATE_FUNC(Issue1288); CL(Issue1305_2),
TESTLAYER_CREATE_FUNC(Issue1288_2); CL(Issue1288),
TESTLAYER_CREATE_FUNC(Issue1327); CL(Issue1288_2),
TESTLAYER_CREATE_FUNC(Issue1398); CL(Issue1327),
CL(Issue1398)
static NEWTESTFUNC createFunctions[] = {
CF(ActionManual),
CF(ActionMove),
CF(ActionRotate),
CF(ActionScale),
CF(ActionSkew),
CF(ActionRotationalSkew),
CF(ActionRotationalSkewVSStandardSkew),
CF(ActionSkewRotateScale),
CF(ActionJump),
CF(ActionCardinalSpline),
CF(ActionCatmullRom),
CF(ActionBezier),
CF(ActionBlink),
CF(ActionFade),
CF(ActionTint),
CF(ActionAnimate),
CF(ActionSequence),
CF(ActionSequence2),
CF(ActionRemoveSelf),
CF(ActionSpawn),
CF(ActionReverse),
CF(ActionDelayTime),
CF(ActionRepeat),
CF(ActionRepeatForever),
CF(ActionRotateToRepeat),
CF(ActionRotateJerk),
CF(ActionCallFunction),
CF(ActionCallFunc),
CF(ActionCallFuncND),
CF(ActionReverseSequence),
CF(ActionReverseSequence2),
CF(ActionOrbit),
CF(ActionFollow),
CF(ActionTargeted),
CF(ActionMoveStacked),
CF(ActionMoveJumpStacked),
CF(ActionMoveBezierStacked),
CF(ActionCardinalSplineStacked),
CF(ActionCatmullRomStacked),
CF(PauseResumeActions),
CF(Issue1305),
CF(Issue1305_2),
CF(Issue1288),
CF(Issue1288_2),
CF(Issue1327),
CF(Issue1398)
}; };
static int sceneIdx=-1; static int sceneIdx=-1;
@ -158,7 +110,7 @@ std::string ActionsDemo::subtitle()
void ActionsDemo::onEnter() void ActionsDemo::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
m_grossini = CCSprite::create(s_pPathGrossini); m_grossini = CCSprite::create(s_pPathGrossini);
@ -177,35 +129,6 @@ void ActionsDemo::onEnter()
m_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3)); m_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3));
m_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3)); m_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3));
m_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2)); m_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2));
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &ActionsDemo::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &ActionsDemo::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &ActionsDemo::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void ActionsDemo::onExit() void ActionsDemo::onExit()
@ -214,7 +137,7 @@ void ActionsDemo::onExit()
m_tamara->release(); m_tamara->release();
m_kathia->release(); m_kathia->release();
CCLayer::onExit(); BaseTest::onExit();
} }
void ActionsDemo::restartCallback(CCObject* pSender) void ActionsDemo::restartCallback(CCObject* pSender)

View File

@ -2,6 +2,7 @@
#define _ActionsTest_H_ #define _ActionsTest_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
////----#include "cocos2d.h" ////----#include "cocos2d.h"
USING_NS_CC; USING_NS_CC;
@ -63,7 +64,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class ActionsDemo : public CCLayer class ActionsDemo : public BaseTest
{ {
protected: protected:
CCSprite* m_grossini; CCSprite* m_grossini;

View File

@ -0,0 +1,79 @@
//
// BaseTest.cpp
// TestCpp
//
// Created by Ricardo Quesada on 6/6/13.
//
//
#include "BaseTest.h"
#include "VisibleRect.h"
#include "testResource.h"
USING_NS_CC;
void BaseTest::onEnter()
{
CCLayer::onEnter();
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &BaseTest::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &BaseTest::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &BaseTest::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
}
void BaseTest::onExit()
{
CCLayer::onExit();
}
std::string BaseTest::title()
{
return "";
}
std::string BaseTest::subtitle()
{
return "";
}
void BaseTest::restartCallback(CCObject* pSender)
{
CCLog("override restart!");
}
void BaseTest::nextCallback(CCObject* pSender)
{
CCLog("override next!");
}
void BaseTest::backCallback(CCObject* pSender)
{
CCLog("override back!");
}

View File

@ -0,0 +1,29 @@
//
// BaseTest.h
// TestCpp
//
// Created by Ricardo Quesada on 6/6/13.
//
//
#ifndef __TestCpp__BaseTest__
#define __TestCpp__BaseTest__
#include "cocos2d.h"
class BaseTest : public cocos2d::CCLayer
{
public:
virtual void onEnter();
virtual void onExit();
virtual std::string title();
virtual std::string subtitle();
virtual void restartCallback(CCObject* pSender);
virtual void nextCallback(CCObject* pSender);
virtual void backCallback(CCObject* pSender);
};
#endif /* defined(__TestCpp__BaseTest__) */

View File

@ -115,7 +115,14 @@ void Box2DTestLayer::initPhysics()
void Box2DTestLayer::createResetButton() void Box2DTestLayer::createResetButton()
{ {
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(Box2DTestLayer::reset)); CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", [](CCObject *sender) {
CCScene* s = new Box2DTestScene();
Box2DTestLayer* child = new Box2DTestLayer();
s->addChild(child);
child->release();
CCDirector::sharedDirector()->replaceScene(s);
s->release();
});
CCMenu *menu = CCMenu::create(reset, NULL); CCMenu *menu = CCMenu::create(reset, NULL);
@ -124,16 +131,6 @@ void Box2DTestLayer::createResetButton()
} }
void Box2DTestLayer::reset(CCObject* sender)
{
CCScene* s = new Box2DTestScene();
Box2DTestLayer* child = new Box2DTestLayer();
s->addChild(child);
child->release();
CCDirector::sharedDirector()->replaceScene(s);
s->release();
}
void Box2DTestLayer::draw() void Box2DTestLayer::draw()
{ {
// //

View File

@ -28,7 +28,6 @@ public:
void initPhysics(); void initPhysics();
void createResetButton(); void createResetButton();
void reset(CCObject* sender);
virtual void draw(); virtual void draw();
void addNewSpriteAtPosition(CCPoint p); void addNewSpriteAtPosition(CCPoint p);

View File

@ -67,9 +67,9 @@ bool MenuLayer::initWithEntryID(int entryId)
addChild(label, 1); addChild(label, 1);
label->setPosition( ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) ); label->setPosition( ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) );
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) ); CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &MenuLayer::backCallback, this, std::placeholders::_1) );
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", std::bind( &MenuLayer::restartCallback, this, std::placeholders::_1) );
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) ); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &MenuLayer::nextCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);

View File

@ -45,7 +45,7 @@ bool Bug1159Layer::init()
sprite_b->setPosition(ccp(s.width/2, s.height/2)); sprite_b->setPosition(ccp(s.width/2, s.height/2));
addChild(sprite_b); addChild(sprite_b);
CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack)); CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), std::bind( &Bug1159Layer::callBack, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(label, NULL); CCMenu *menu = CCMenu::create(label, NULL);
menu->setPosition(ccp(s.width - 200.0f, 50.0f)); menu->setPosition(ccp(s.width - 200.0f, 50.0f));
addChild(menu); addChild(menu);

View File

@ -31,9 +31,9 @@ void Bug422Layer::reset()
removeChild(node, false); removeChild(node, false);
// [self removeChildByTag:localtag-1 cleanup:NO]; // [self removeChildByTag:localtag-1 cleanup:NO];
CCMenuItem *item1 = CCMenuItemFont::create("One", this, menu_selector(Bug422Layer::menuCallback)); CCMenuItem *item1 = CCMenuItemFont::create("One", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
CCLog("MenuItemFont: %p", item1); CCLog("MenuItemFont: %p", item1);
CCMenuItem *item2 = CCMenuItemFont::create("Two", this, menu_selector(Bug422Layer::menuCallback)); CCMenuItem *item2 = CCMenuItemFont::create("Two", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
CCMenu *menu = CCMenu::create(item1, item2, NULL); CCMenu *menu = CCMenu::create(item1, item2, NULL);
menu->alignItemsVertically(); menu->alignItemsVertically();

View File

@ -21,13 +21,13 @@ bool Bug458Layer::init()
// [question setContentSize:CGSizeMake(50,50)]; // [question setContentSize:CGSizeMake(50,50)];
// [question2 setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)];
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer)); CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100); CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100);
question->release(); question->release();
question2->release(); question2->release();
CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100); CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100);
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer)); CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
CCMenu* menu = CCMenu::create(sprite, sprite2, NULL); CCMenu* menu = CCMenu::create(sprite, sprite2, NULL);
menu->alignItemsVerticallyWithPadding(100); menu->alignItemsVerticallyWithPadding(100);
menu->setPosition(ccp(size.width / 2, size.height / 2)); menu->setPosition(ccp(size.width / 2, size.height / 2));

View File

@ -46,7 +46,7 @@ bool Bug914Layer::init()
// create and initialize a Label // create and initialize a Label
CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64); CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64);
CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart)); CCMenuItem *item1 = CCMenuItemFont::create("restart", std::bind( &Bug914Layer::restart, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(item1, NULL); CCMenu *menu = CCMenu::create(item1, NULL);
menu->alignItemsVertically(); menu->alignItemsVertically();

View File

@ -9,38 +9,42 @@
#include "Bug-1159.h" #include "Bug-1159.h"
#include "Bug-1174.h" #include "Bug-1174.h"
#define TEST_BUG(bugNO) \ #define TEST_BUG(__bug__) \
{ \ { \
CCScene* pScene = CCScene::create(); \ CCScene* pScene = CCScene::create(); \
Bug##bugNO##Layer* pLayer = new Bug##bugNO##Layer(); \ Bug##__bug__##Layer* pLayer = new Bug##__bug__##Layer(); \
pLayer->init(); \ pLayer->init(); \
pScene->addChild(pLayer); \ pScene->addChild(pLayer); \
CCDirector::sharedDirector()->replaceScene(pScene); \ CCDirector::sharedDirector()->replaceScene(pScene); \
pLayer->autorelease(); \ pLayer->autorelease(); \
} }
enum enum
{ {
MAX_COUNT = 9,
LINE_SPACE = 40, LINE_SPACE = 40,
kItemTagBasic = 5432, kItemTagBasic = 5432,
}; };
static CCPoint s_tCurPos = CCPointZero; static CCPoint s_tCurPos = CCPointZero;
const std::string testsName[MAX_COUNT] = struct {
{ const char *test_name;
"Bug-350", std::function<void(CCObject*)> callback;
"Bug-422", } g_bugs[] = {
"Bug-458", { "Bug-350", [](CCObject* sender){ TEST_BUG(350)} },
"Bug-624", { "Bug-422", [](CCObject* sender){ TEST_BUG(422)} },
"Bug-886", { "Bug-458", [](CCObject* sender){ TEST_BUG(458)} },
"Bug-899", { "Bug-624", [](CCObject* sender){ TEST_BUG(624)} },
"Bug-914", { "Bug-886", [](CCObject* sender){ TEST_BUG(886)} },
"Bug-1159", { "Bug-899", [](CCObject* sender){ TEST_BUG(899)} },
"Bug-1174" { "Bug-914", [](CCObject* sender){ TEST_BUG(914)} },
{ "Bug-1159", [](CCObject* sender){ TEST_BUG(1159)} },
{ "Bug-1174", [](CCObject* sender){ TEST_BUG(1174)} },
}; };
static const int g_maxitems = sizeof(g_bugs) / sizeof(g_bugs[0]);
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// //
// BugsTestMainLayer // BugsTestMainLayer
@ -54,10 +58,9 @@ void BugsTestMainLayer::onEnter()
m_pItmeMenu = CCMenu::create(); m_pItmeMenu = CCMenu::create();
CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(24); CCMenuItemFont::setFontSize(24);
for (int i = 0; i < MAX_COUNT; ++i) for (int i = 0; i < g_maxitems; ++i)
{ {
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this, CCMenuItemFont* pItem = CCMenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback);
menu_selector(BugsTestMainLayer::menuCallback));
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE)); pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
m_pItmeMenu->addChild(pItem, kItemTagBasic + i); m_pItmeMenu->addChild(pItem, kItemTagBasic + i);
} }
@ -67,45 +70,6 @@ void BugsTestMainLayer::onEnter()
setTouchEnabled(true); setTouchEnabled(true);
} }
void BugsTestMainLayer::menuCallback(CCObject* pSender)
{
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
int nIndex = pItem->getZOrder() - kItemTagBasic;
switch (nIndex)
{
case 0:
TEST_BUG(350);
break;
case 1:
TEST_BUG(422);
break;
case 2:
TEST_BUG(458);
break;
case 3:
TEST_BUG(624);
break;
case 4:
TEST_BUG(886);
break;
case 5:
TEST_BUG(899);
break;
case 6:
TEST_BUG(914);
break;
case 7:
TEST_BUG(1159);
break;
case 8:
TEST_BUG(1174);
break;
default:
break;
}
}
void BugsTestMainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) void BugsTestMainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{ {
CCSetIterator it = pTouches->begin(); CCSetIterator it = pTouches->begin();
@ -131,9 +95,9 @@ void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
return; return;
} }
if (nextPos.y > ((MAX_COUNT + 1)* LINE_SPACE - winSize.height)) if (nextPos.y > ((g_maxitems + 1)* LINE_SPACE - winSize.height))
{ {
m_pItmeMenu->setPosition(ccp(0, ((MAX_COUNT + 1)* LINE_SPACE - winSize.height))); m_pItmeMenu->setPosition(ccp(0, ((g_maxitems + 1)* LINE_SPACE - winSize.height)));
return; return;
} }
@ -153,8 +117,7 @@ void BugsTestBaseLayer::onEnter()
CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontName("Arial");
CCMenuItemFont::setFontSize(24); CCMenuItemFont::setFontSize(24);
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this, CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", std::bind( &BugsTestBaseLayer::backCallback, this, std::placeholders::_1));
menu_selector(BugsTestBaseLayer::backCallback));
pMainItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); pMainItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu* pMenu = CCMenu::create(pMainItem, NULL); CCMenu* pMenu = CCMenu::create(pMainItem, NULL);
pMenu->setPosition( CCPointZero ); pMenu->setPosition( CCPointZero );

View File

@ -7,7 +7,6 @@ class BugsTestMainLayer : public CCLayer
{ {
public: public:
virtual void onEnter(); virtual void onEnter();
void menuCallback(CCObject* pSender);
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent); virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);

View File

@ -50,7 +50,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
// menu for debug layer // menu for debug layer
CCMenuItemFont::setFontSize(18); CCMenuItemFont::setFontSize(18);
CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", this, menu_selector(ChipmunkTestLayer::toggleDebugCallback)); CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", std::bind( &ChipmunkTestLayer::toggleDebugCallback, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(item, NULL); CCMenu *menu = CCMenu::create(item, NULL);
this->addChild(menu); this->addChild(menu);
@ -147,7 +147,7 @@ void ChipmunkTestLayer::update(float delta)
void ChipmunkTestLayer::createResetButton() void ChipmunkTestLayer::createResetButton()
{ {
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(ChipmunkTestLayer::reset)); CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &ChipmunkTestLayer::reset, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(reset, NULL); CCMenu *menu = CCMenu::create(reset, NULL);

View File

@ -92,40 +92,13 @@ static CCLayer* restartAction()
bool BaseClippingNodeTest::init() bool BaseClippingNodeTest::init()
{ {
if (CCLayer::init()) { if (BaseTest::init()) {
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSprite *background = CCSprite::create(s_back3); CCSprite *background = CCSprite::create(s_back3);
background->setAnchorPoint( CCPointZero ); background->setAnchorPoint( CCPointZero );
background->setPosition( CCPointZero ); background->setPosition( CCPointZero );
this->addChild(background, -1); this->addChild(background, -1);
CCLabelTTF *label = CCLabelTTF::create(this->title().c_str(), "Arial", 32);
this->addChild(label, 1, kTagTitleLabel);
label->setPosition( ccp(s.width / 2, s.height - 50));
std::string subtitleText = this->subtitle();
if (subtitleText.length() > 0) {
CCLabelTTF *subtitle = CCLabelTTF::create(subtitleText.c_str(), "Thonburi", 16);
this->addChild(subtitle, 1, kTagSubtitleLabel);
subtitle->setPosition(ccp(s.width / 2, s.height - 80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2,
this, menu_selector(BaseClippingNodeTest::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2,
this, menu_selector(BaseClippingNodeTest::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2,
this, menu_selector(BaseClippingNodeTest::nextCallback));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( ccp(s.width / 2 - item2->getContentSize().width * 2, item2->getContentSize().height / 2));
item2->setPosition( ccp(s.width / 2, item2->getContentSize().height / 2));
item3->setPosition( ccp(s.width / 2 + item2->getContentSize().width * 2, item2->getContentSize().height / 2));
this->addChild(menu, 1);
this->setup(); this->setup();
return true; return true;
} }

View File

@ -2,8 +2,9 @@
#define __CLIPPINGNODETEST_H__ #define __CLIPPINGNODETEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class BaseClippingNodeTest : public CCLayer class BaseClippingNodeTest : public BaseTest
{ {
public: public:
~BaseClippingNodeTest(); ~BaseClippingNodeTest();

View File

@ -63,7 +63,7 @@ m_nSoundId(0)
//#else //#else
CCLabelTTF* label = CCLabelTTF::create(testItems[i].c_str(), "Arial", 24); CCLabelTTF* label = CCLabelTTF::create(testItems[i].c_str(), "Arial", 24);
//#endif //#endif
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(CocosDenshionTest::menuCallback)); CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, std::bind( &CocosDenshionTest::menuCallback, this, std::placeholders::_1));
m_pItmeMenu->addChild(pMenuItem, i + 10000); m_pItmeMenu->addChild(pMenuItem, i + 10000);
pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));

View File

@ -76,41 +76,12 @@ std::string ConfigurationBase::subtitle()
void ConfigurationBase::onEnter() void ConfigurationBase::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
// add title and subtitle
std::string str = title();
const char * pTitle = str.c_str();
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
addChild(label, 1);
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
}
// add menu
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ConfigurationBase::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ConfigurationBase::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ConfigurationBase::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
void ConfigurationBase::onExit() void ConfigurationBase::onExit()
{ {
CCLayer::onExit(); BaseTest::onExit();
} }
void ConfigurationBase::restartCallback(CCObject* pSender) void ConfigurationBase::restartCallback(CCObject* pSender)

View File

@ -2,6 +2,7 @@
#define __CONFIGURATIONTEST_H__ #define __CONFIGURATIONTEST_H__
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
USING_NS_CC; USING_NS_CC;
@ -15,7 +16,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class ConfigurationBase : public CCLayer class ConfigurationBase : public BaseTest
{ {
protected: protected:

View File

@ -66,33 +66,7 @@ BaseLayer::BaseLayer()
void BaseLayer::onEnter() void BaseLayer::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition(ccp(s.width/2, s.height-50));
string subTitle = subtitle();
if (subTitle.size() > 0)
{
CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
addChild(l, 1);
l->setPosition(ccp(s.width/2, s.height-80));
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(BaseLayer::backCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(BaseLayer::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(BaseLayer::nextCallback));
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(ccp(s.width/2, item2->getContentSize().height/2));
item3->setPosition(ccp(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 100);
} }
void BaseLayer::restartCallback(cocos2d::CCObject *pSender) void BaseLayer::restartCallback(cocos2d::CCObject *pSender)

View File

@ -3,10 +3,11 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
#include <string> #include <string>
class BaseLayer : public CCLayer class BaseLayer : public BaseTest
{ {
public: public:
BaseLayer(); BaseLayer();

View File

@ -333,7 +333,7 @@ CCLayer* restartEffectAdvanceAction()
void EffectAdvanceTextLayer::onEnter(void) void EffectAdvanceTextLayer::onEnter(void)
{ {
CCLayer::onEnter(); BaseTest::onEnter();
CCSprite *bg = CCSprite::create("Images/background3.png"); CCSprite *bg = CCSprite::create("Images/background3.png");
addChild(bg, 0, kTagBackground); addChild(bg, 0, kTagBackground);
@ -352,33 +352,6 @@ void EffectAdvanceTextLayer::onEnter(void)
CCActionInterval* sc2 = CCScaleBy::create(2, 5); CCActionInterval* sc2 = CCScaleBy::create(2, 5);
CCActionInterval* sc2_back = sc2->reverse(); CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) ); tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) );
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
std::string strSubtitle = subtitle();
if( ! strSubtitle.empty() )
{
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
addChild(l, 101);
l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
}
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
} }
EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void) EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)

View File

@ -3,8 +3,9 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class EffectAdvanceTextLayer: public CCLayer class EffectAdvanceTextLayer: public BaseTest
{ {
protected: protected:
CCTextureAtlas* m_atlas; CCTextureAtlas* m_atlas;

View File

@ -337,8 +337,10 @@ void EffectTestScene::runThisTest()
#define SID_RESTART 1 #define SID_RESTART 1
TextLayer::TextLayer(void) TextLayer::TextLayer(void)
: BaseTest()
{ {
initWithColor( ccc4(32,128,32,255) ); CCLayerColor *background = CCLayerColor::create( ccc4(32,128,32,255) );
this->addChild(background,-20);
CCNode* node = CCNode::create(); CCNode* node = CCNode::create();
CCActionInterval* effect = getAction(); CCActionInterval* effect = getAction();
@ -364,25 +366,6 @@ TextLayer::TextLayer(void)
CCActionInterval* sc2_back = sc2->reverse(); CCActionInterval* sc2_back = sc2->reverse();
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) ); tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
addChild(label);
label->setTag( kTagLabel );
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
schedule( schedule_selector(TextLayer::checkAnim) ); schedule( schedule_selector(TextLayer::checkAnim) );
} }
@ -413,7 +396,7 @@ TextLayer* TextLayer::create()
void TextLayer::onEnter() void TextLayer::onEnter()
{ {
CCLayer::onEnter(); BaseTest::onEnter();
} }
void TextLayer::newScene() void TextLayer::newScene()

View File

@ -2,6 +2,7 @@
#define _EFFECTS_TEST_H_ #define _EFFECTS_TEST_H_
#include "../testBasic.h" #include "../testBasic.h"
#include "../BaseTest.h"
class EffectTestScene : public TestScene class EffectTestScene : public TestScene
{ {
@ -9,7 +10,7 @@ public:
virtual void runThisTest(); virtual void runThisTest();
}; };
class TextLayer : public CCLayerColor class TextLayer : public BaseTest
{ {
protected: protected:
//UxString m_strTitle; //UxString m_strTitle;

View File

@ -42,8 +42,7 @@ bool CCControlScene::init()
{ {
if (CCLayer::init()) if (CCLayer::init())
{ {
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this, CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &CCControlScene::toExtensionsMainLayer, this, std::placeholders::_1));
menu_selector(CCControlScene::toExtensionsMainLayer));
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL); CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
pBackMenu->setPosition( CCPointZero ); pBackMenu->setPosition( CCPointZero );
@ -66,9 +65,9 @@ bool CCControlScene::init()
addChild(m_pSceneTitleLabel, 1); addChild(m_pSceneTitleLabel, 1);
// Add the menu // Add the menu
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback)); CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &CCControlScene::previousCallback, this, std::placeholders::_1));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback)); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &CCControlScene::restartCallback, this, std::placeholders::_1));
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback)); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &CCControlScene::nextCallback, this, std::placeholders::_1));
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL); CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
menu->setPosition(CCPointZero); menu->setPosition(CCPointZero);

View File

@ -27,7 +27,7 @@ EditBoxTest::EditBoxTest()
addChild(m_pTTFShowEditReturn); addChild(m_pTTFShowEditReturn);
// Back Menu // Back Menu
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(EditBoxTest::toExtensionsMainLayer)); CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &EditBoxTest::toExtensionsMainLayer, this, std::placeholders::_1));
itemBack->setPosition(ccp(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25)); itemBack->setPosition(ccp(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL); CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero); menuBack->setPosition(CCPointZero);

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