| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 | /****************************************************************************Copyright (c) 2012-2013 cocos2d-x.orghttp://www.cocos2d-x.orgPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 INTHE SOFTWARE.****************************************************************************/#include "ProtocolShare.h"#include "PluginUtilsIOS.h"#import "InterfaceShare.h"namespace cocos2d { namespace plugin {ProtocolShare::ProtocolShare(): _listener(NULL){}ProtocolShare::~ProtocolShare(){}void ProtocolShare::configDeveloperInfo(TShareDeveloperInfo devInfo){    if (devInfo.empty())    {        PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName());        return;    }    else    {        PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);        assert(pData != NULL);                id ocObj = pData->obj;        if ([ocObj conformsToProtocol:@protocol(InterfaceShare)]) {            NSObject<InterfaceShare>* curObj = ocObj;            NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo);            [curObj configDeveloperInfo:pDict];        }    }}void ProtocolShare::share(TShareInfo info){    if (info.empty())    {        if (NULL != _listener)        {            onShareResult(kShareFail, "Share info error");        }        PluginUtilsIOS::outputLog("The Share info of %s is empty!", this->getPluginName());        return;    }    else    {        PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);        assert(pData != NULL);                id ocObj = pData->obj;        if ([ocObj conformsToProtocol:@protocol(InterfaceShare)]) {            NSObject<InterfaceShare>* curObj = ocObj;            NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&info);            [curObj share:pDict];        }    }}void ProtocolShare::share(TShareInfo &info,ProtocolShareCallback &cb){    setCallback(cb);    share(info);}void ProtocolShare::setResultListener(ShareResultListener* pListener){	_listener = pListener;}    ShareResultListener* ProtocolShare::getResultListener(){    return _listener;}void ProtocolShare::onShareResult(ShareResultCode ret, const char* msg){    if (_listener)    {    	_listener->onShareResult(ret, msg);    }    else    {        PluginUtilsIOS::outputLog("Share result listener of %s is null!", this->getPluginName());    }    PluginUtilsIOS::outputLog("Share result of %s is : %d(%s)", this->getPluginName(), (int) ret, msg);}}} // namespace cocos2d { namespace plugin {
 |