void MyShareManager::loadSharePlugin()
{
	if (s_pRetListener == NULL)
	{
		s_pRetListener = new MyShareResult();
	}

	{
		// init twitter plugin
		s_pTwitter = dynamic_cast<ProtocolShare*>(PluginManager::getInstance()->loadPlugin("ShareTwitter"));
		if (NULL != s_pTwitter)
		{
			TShareDeveloperInfo pTwitterInfo;

			/* Warning: must set your twiiter dev info here */
			// pTwitterInfo["TwitterKey"] = "your consumerkey";
			// pTwitterInfo["TwitterSecret"] = "your consumersecret";

			if (pTwitterInfo.empty())
			{
				char msg[256] = { 0 };
				sprintf(msg, "Developer info is empty. PLZ fill your twitter info in %s(nearby line %d)", __FILE__, __LINE__);
				MessageBox(msg, "Twitter Warning");
			}
			s_pTwitter->setDebugMode(true);
			s_pTwitter->configDeveloperInfo(pTwitterInfo);
			s_pTwitter->setResultListener(s_pRetListener);
		}
	}

	{
		s_pWeibo = dynamic_cast<ProtocolShare*>(PluginManager::getInstance()->loadPlugin("ShareWeibo"));
		if (NULL != s_pWeibo)
		{
			TShareDeveloperInfo pWeiboInfo;
			// pWeiboInfo["WeiboAppKey"] = "your app key";
            // pWeiboInfo["WeiboAppSecret"] = "your app secret";
			// pWeiboInfo["WeiboRedirectUrl"] = "your redirect url";

			if (pWeiboInfo.empty())
			{
				char msg[256] = { 0 };
				sprintf(msg, "Developer info is empty. PLZ fill your weibo info in %s(nearby line %d)", __FILE__, __LINE__);
				MessageBox(msg, "Weibo Warning");
			}

			s_pWeibo->setDebugMode(true);
			s_pWeibo->configDeveloperInfo(pWeiboInfo);
			s_pWeibo->setResultListener(s_pRetListener);
		}
	}
}
Esempio n. 2
0
void ProtocolShare::configDeveloperInfo(TShareDeveloperInfo devInfo)
{
    if (devInfo.empty())
    {
        PluginUtils::outputLog("ProtocolShare", "The developer info is empty!");
        return;
    }
    else
    {
        PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
    	PluginJniMethodInfo t;
        if (PluginJniHelper::getMethodInfo(t
    		, pData->jclassName.c_str()
    		, "configDeveloperInfo"
    		, "(Ljava/util/Hashtable;)V"))
    	{
        	// generate the hashtable from map
        	jobject obj_Map = PluginUtils::createJavaMapObject(&devInfo);

            // invoke java method
            t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map);
            t.env->DeleteLocalRef(obj_Map);
            t.env->DeleteLocalRef(t.classID);
        }
    }
}