//-------------------------------------
// FuseSDKVirtualGoodsOfferAccepted
// Params: string purchaseCurrency, float purchasePrice, string itemName, int itemAmount
//-------------------------------------
void FuseSDKVirtualGoodsOfferAccepted(JNIEnv* env, jobject obj, jstring currency, float price, jstring itemName, int amount, int startTime, int endTime, int currencyID, int virtualGoodsID)
{
    struct paramList
    {
        const char* purchaseCurrency;
        float purchasePrice;
        const char* itemName;
        int itemAmount;
        int startTime;
        int endTime;
        int currencyID;
        int virtualGoodsID;
    };
    paramList params;
    params.itemAmount = amount;
    params.purchasePrice = price;
    params.purchaseCurrency = s3eEdkGetStringUTF8Chars(currency);
    params.itemName = s3eEdkGetStringUTF8Chars(itemName);
    params.startTime = startTime;
    params.endTime = endTime;
    params.currencyID = currencyID;
    params.virtualGoodsID = virtualGoodsID;
    IwTrace(FuseSDK, ("FuseSDKVirtualGoodsOfferAccepted(%s, %f, %s, %i, %i, %i, %i, %i)", params.purchaseCurrency, params.purchasePrice, params.itemName, params.itemAmount, params.startTime, params.endTime, params.currencyID, params.virtualGoodsID));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_VIRTUALGOODSOFFER_ACCEPTED, &params, sizeof(paramList));
}
  //Native functions called by java
void s3eNOpenFeint_NOFLoginCallback(JNIEnv *env, jobject _this, jstring userId, bool loginResult)
{
    //loginResult is really s3eResult
  bool bInIsCopy = true;
  
  const char *tmpUserId = getCString(userId);
  if(loginResult)
    IwTrace(NOPENFEINT, ("User logged in %s",tmpUserId));
  else
    IwTrace(NOPENFEINT, ("User logged out %s",tmpUserId));  
  
  if(s3eEdkCallbacksIsRegistered(S3E_EXT_NOPENFEINT_HASH, 
                                 S3E_NOPENFEINT_CALLBACK_PLAYER_LOGGEDIN)
     == false)
		return; // no callback registered for this one
	
	
	s3eNOFPlayerInfo info;
	
  info.playerId = (char*)tmpUserId; // lets just hope our consumer doesn't change it. not that it matters much
  
	s3eEdkCallbacksEnqueue(S3E_EXT_NOPENFEINT_HASH,
                         S3E_NOPENFEINT_CALLBACK_PLAYER_LOGGEDIN,
                         (void*)&info,
                         sizeof(info),
                         NULL,
                         S3E_FALSE,
                         NULL,
                         NULL);	
}
void NotificationReceivedCallback(JNIEnv* env, jobject _this, jstring m_Message, jstring m_AdditionalData, bool m_isActive) {
	const char* nativeMessageStr = NULL;
	const char* nativeAdditionalDataStr = NULL;
	
	if (m_Message != NULL)
		nativeMessageStr = env->GetStringUTFChars(m_Message, 0);
	if (m_AdditionalData != NULL)
		nativeAdditionalDataStr = env->GetStringUTFChars(m_AdditionalData, 0);
	
	GameThriveNotificationReceivedResult result;
	result.m_Message = nativeMessageStr;
	result.m_AdditionalData = nativeAdditionalDataStr;
	result.m_isActive = m_isActive;
	
	s3eEdkCallbacksEnqueue(S3E_DEVICE_GAMETHRIVE,
							S3E_GAMETHRIVE_CALLBACK_NOTIFICATION_RECEIVED,
							&result,
							sizeof(result),
							NULL,
							S3E_FALSE); // FALSE, not a one shot callback.
	
	// TODO: Fix very very small memory leak(1 KiBs or less).
	// 		 The 2 lines below fixes the leak however then the const char* pointer is invalid to the callback receiver.
	//env->ReleaseStringUTFChars(m_Message, nativeMessageStr);
	//env->ReleaseStringUTFChars(m_AdditionalData, nativeAdditionalDataStr);
}
JNIEXPORT void JNICALL native_onNotificationsRegisterError(JNIEnv* env, jclass clazz, jstring message) 
{
	AutoJniStringBuffer messageBuffer(env, message);
    g_errorMessage = std::string(messageBuffer.buffer);
	
	s3eEdkCallbacksEnqueue(S3E_EXT_PUSHWOOSH_HASH, S3E_PUSHWOOSH_REGISTRATION_ERROR, (char *)g_errorMessage.c_str());
}
void JNICALL amazonGameCircle_onGetPlayerAlias(JNIEnv* env, jobject obj, jstring alias) {
    char* aliasNative = javaStringToNative( alias );
    
    s3eEdkCallbacksEnqueue(S3E_EXT_GAMECIRCLE_HASH, S3E_GAMECIRCLE_PLAYER_ALIAS_CALLBACK, aliasNative,
                           strlen(aliasNative)+1, NULL, false,
                           0, 0);

}
void JNICALL s3eKiip_saveMomentCompletionCallback( JNIEnv* env, jobject obj, jobject param )
{
	s3eDebugOutputString("s3eKiip_saveMomentCompletionCallback: start");

	const char* pItemData = jstringToChar( env, (jstring) param );

	s3eEdkCallbacksEnqueue(	S3E_EXT_KIIP_HASH, S3EKIIP_SAVE_MOMENT_COMPLETION, (void*)pItemData, 
		0 , NULL, false, &s3eKiip_ReleaseStringCallback, (void*)pItemData );
}
void CallbacksRequestProducts::OnCancel()
{
	IwTrace(ODK, ("OnCancel"));

	s3eRequestProductsCancelEvent event;

	m_dataRequestProductsCancelEvent = event; //don't send a temp pointer
	s3eEdkCallbacksEnqueue(S3E_EXT_ODK_HASH, S3E_ODK_CALLBACKS_REQUEST_PRODUCTS_ON_CANCEL, &m_dataRequestProductsCancelEvent);
}
JNIEXPORT void JNICALL native_onPushReceived(JNIEnv* env, jclass clazz, jstring text, jstring customData)
{
    {
        AutoJniStringBuffer textBuffer(env, text);
        g_pushPayload = std::string(textBuffer.buffer);
    }

	s3eEdkCallbacksEnqueue(S3E_EXT_PUSHWOOSH_HASH, S3E_PUSHWOOSH_MESSAGE_RECEIVED, (char *)g_pushPayload.c_str());
}
void JNICALL s3eKiip_swarmStartCallback( JNIEnv* env, jobject obj, jobject param )
{
	s3eDebugOutputString("s3eKiip_swarmStartCallback: start");

	const char* pItemData = jstringToChar( env, (jstring) param );

	s3eEdkCallbacksEnqueue(	S3E_EXT_KIIP_HASH, S3EKIIP_SWARM_START, (void*)pItemData, 
		0 , NULL, false, &s3eKiip_ReleaseStringCallback, (void*)pItemData );
}
JNIEXPORT void JNICALL native_onNotificationsRegistered(JNIEnv* env, jclass clazz, jstring token)
{
    IwTrace(PUSHWOOSH, ("PUSHWOOSH: registered for notifications"));
    {
        AutoJniStringBuffer tokenBuffer(env, token);    
        g_pushToken = std::string(tokenBuffer.buffer);
    }

	s3eEdkCallbacksEnqueue(S3E_EXT_PUSHWOOSH_HASH, S3E_PUSHWOOSH_REGISTRATION_SUCCEEDED, (char *)g_pushToken.c_str());
}
//-------------------------------------
// FuseSDKTimeUpdated
// Params: int timestamp
//-------------------------------------
void FuseSDKTimeUpdated(JNIEnv* env, jobject obj, jint timestamp)
{
	struct paramList
	{
		int timestamp;
	};
	paramList params;
	params.timestamp = timestamp;
    IwTrace(FuseSDK, ("FuseSDKTimeUpdated(%i)", timestamp));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_TIME_UPDATED, &params, sizeof(paramList));
}
//-------------------------------------
// FuseSDKNotificationAction
// Params: string action
//-------------------------------------
void FuseSDKNotificationAction(JNIEnv* env, jobject obj, jstring action)
{
	struct paramList
	{
		const char* action;
	};
	paramList params;
	params.action = s3eEdkGetStringUTF8Chars(action);
    IwTrace(FuseSDK, ("FuseSDKNotificationAction(%s)", params.action));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_NOTIFICATION_ACTION, &params, sizeof(paramList));
}
//-------------------------------------
// FuseSDKLoginError
// Params: int error
//-------------------------------------
void FuseSDKLoginError(JNIEnv* env, jobject obj, jint result)
{
	struct paramList
	{
		int error;
	};
	paramList params;
	params.error = result;
    IwTrace(FuseSDK, ("FuseSDKLoginError(%i)", result));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_SESSION_LOGIN_ERROR, &params, sizeof(paramList));
}
void CallbacksRequestProducts::OnFailure(int errorCode, const std::string& errorMessage)
{
	char buffer[256];
	sprintf(buffer, "OnFailure errorCode=%d errorMessage=%s", errorCode, errorMessage.c_str());
	IwTrace(ODK, (buffer));

	s3eRequestProductsFailureEvent event;
	event.m_errorCode = errorCode;
	sprintf(event.m_errorMessage, "%s", errorMessage.c_str());

	m_dataRequestProductsFailureEvent = event; //don't send a temp pointer
	s3eEdkCallbacksEnqueue(S3E_EXT_ODK_HASH, S3E_ODK_CALLBACKS_REQUEST_PRODUCTS_ON_FAILURE, &m_dataRequestProductsFailureEvent);
}
void FuseGameConfigurationReceived(JNIEnv* env, jobject obj)
{
	IwTrace(FuseSDK, ("FuseGameConfigurationReceived()"));

	struct paramList
	{
		cfuhash_table_t* gameConfig;
	};
	paramList params;
	params.gameConfig = gameConfig;

	s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_GAME_CONFIGURATION_RECEIVED, &params, sizeof(paramList));
}
//-------------------------------------
// FuseSDKAccountLoginComplete
// Params: int accountType, string accountID
// Note: accountType is defined in FuseSDK.h as FuseAccountType
//-------------------------------------
void FuseSDKAccountLoginComplete(JNIEnv* env, jobject obj, int accountType, jstring accountID)
{
	struct paramList
	{
		int accountType;
		const char* accountID;
	};
	paramList params;
	params.accountType = accountType;
	params.accountID = s3eEdkGetStringUTF8Chars(accountID);
    IwTrace(FuseSDK, ("FuseSDKAccountLoginComplete(%i, %s)", params.accountType, params.accountID));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_ACCOUNT_LOGIN_COMPLETE, &params, sizeof(paramList));
}
//----------------------------------------------------------------------------------------
// Ad Callbacks
//-------------------------------------
// FuseSDKAdAvailabilityResponse
// Params: int available, int error
//-------------------------------------
void FuseSDKAdAvailabilityResponse(JNIEnv* env, jobject obj, jint available, jint error)
{
	struct paramList
	{
		int available;
		int error;
	};
	paramList params;
	params.available = available;
	params.error = error;

    IwTrace(FuseSDK, ("FuseSDKAdAvailabilityResponse(%i, %i)", available, error));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_AD_AVAILABILITY_RESPONSE, &params, sizeof(paramList));
}
//-------------------------------------
// FuseSDKAdDidShow
// Params: int networkID, int mediaType
//-------------------------------------
void FuseSDKAdDidShow(JNIEnv* env, jobject obj, int networkID, int mediaType)
{
    struct paramList
    {
        int networkID;
        int mediaType;
    };
    paramList params;
    params.networkID = networkID;
    params.mediaType = mediaType;
    
    IwTrace(FuseSDK, ("FuseSDKAdDidShow(%i, %i)", networkID, mediaType));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_AD_DID_SHOW, &params, sizeof(paramList));
}
//-------------------------------------
// FuseSDKPurchaseVerification
// Params: int verified, string transaction_id, string original_transaction_id
//-------------------------------------
void FuseSDKPurchaseVerification(JNIEnv* env, jobject obj, int verified, jstring t_id, jstring o_id)
{
    struct paramList
    {
        int verified;
        const char* transaction_id;
        const char* original_transaction_id;
    };
    paramList params;
    params.verified = verified;
    params.transaction_id = s3eEdkGetStringUTF8Chars(t_id);
    params.original_transaction_id = s3eEdkGetStringUTF8Chars(o_id);
    IwTrace(FuseSDK, ("FuseSDKPurchaseVerification(%i, %s, %s)", params.verified, params.transaction_id, params.original_transaction_id));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_PURCHASE_VERIFIED, &params, sizeof(paramList));
}
void TagsReceivedCallback(JNIEnv* env, jobject _this, jstring m_Tags) {
	const char* nativeTagsStr = env->GetStringUTFChars(m_Tags, 0);
	
	GameThriveTagsReceivedResult result;
	result.m_Tags = nativeTagsStr;
	
	s3eEdkCallbacksEnqueue(S3E_DEVICE_GAMETHRIVE,
							S3E_GAMETHRIVE_CALLBACK_TAGS_RECEIVED,
							&result,
							sizeof(result),
							NULL,
							S3E_TRUE); // TRUE, a one shot callback.
	
	// TODO: Fix very very small memory leak(1 KiBs or less).
	// 		 The line below fixes the leak however then the const char* pointer is invalid to the callback receiver.
	//env->ReleaseStringUTFChars(m_Tags, nativeTagsStr);
}
void JNICALL amazonGameCircle_onBlobCallBack(JNIEnv* env, jobject obj, jint status, jint errorCode, jbyteArray data) {
    
    s3eGameCircleBlobResponse response;
    response.m_Status = (s3eGameCircleBlobCallbackStatus)status;
    response.m_ErrorCode = (s3eGameCircleErrorCode)errorCode;
    response.m_Data = 0;
    response.m_DataLen = 0;

    if (data) {
        response.m_DataLen = env->GetArrayLength(data);
        char* nativeData = new char[response.m_DataLen];
        env->GetByteArrayRegion(data, 0, response.m_DataLen, (jbyte*)nativeData);
        response.m_Data = nativeData;
    }

    s3eEdkCallbacksEnqueue(S3E_EXT_GAMECIRCLE_HASH, S3E_GAMECIRCLE_SYNCHRONIZE_BLOB_CALLBACK, &response,
                           sizeof(response), NULL, false,
                           &amazonGameCircle_onBlobCallBackClean, 0);
}
//-------------------------------------
// FuseSDKRewardedAdComplete
// Params: string preMessage, string rewardMessage, string rewardItem, int rewardAmount
//-------------------------------------
void FuseSDKRewardedAdComplete(JNIEnv* env, jobject obj, jstring preMessage, jstring rewardMessage, jstring rewardItem, int rewardAmount, int itemID)
{
    struct paramList
    {
        const char* preMessage;
        const char* rewardMessage;
        const char* rewardItem;
        int rewardAmount;
        int itemID;
    };
    paramList params;
    params.rewardAmount = rewardAmount;
    params.preMessage = s3eEdkGetStringUTF8Chars(preMessage);
    params.rewardMessage = s3eEdkGetStringUTF8Chars(rewardMessage);
    params.rewardItem = s3eEdkGetStringUTF8Chars(rewardItem);
    params.itemID = itemID;
    IwTrace(FuseSDK, ("FuseSDKRewardedAdComplete(%s, %s, %s, %i, %i)", params.preMessage, params.rewardMessage, params.rewardItem, params.rewardAmount, params.itemID));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_REWARDED_AD_COMPLETED, &params, sizeof(paramList));
}
void IdsAvailableCallback(JNIEnv* env, jobject _this, jstring m_PlayerID, jstring m_PushToken) {
	const char* nativePlayerIDStr = env->GetStringUTFChars(m_PlayerID, 0);
	const char* nativePushTokenStr = env->GetStringUTFChars(m_PushToken, 0);
	
	GameThriveIdsAvailableResult result;
	result.m_PlayerID = nativePlayerIDStr;
	result.m_PushToken = nativePushTokenStr;
	
	s3eEdkCallbacksEnqueue(S3E_DEVICE_GAMETHRIVE,
							S3E_GAMETHRIVE_CALLBACK_IDS_AVAILABLE,
							&result,
							sizeof(result),
							NULL,
							S3E_FALSE); // FALSE, not a one shot callback.
	
	// TODO: Fix very very small memory leak(1 KiBs or less).
	// 		 The 2 lines below fixes the leak however then the const char* pointer is invalid to the callback receiver.
	//env->ReleaseStringUTFChars(m_PlayerID, nativePlayerIDStr);
	//env->ReleaseStringUTFChars(m_PushToken, nativePushTokenStr);
}
//-------------------------------------
// FuseSDKIAPOfferAccepted
// Params: float productPrice, int itemAmount, string itemName, string productID
//-------------------------------------
void FuseSDKIAPOfferAccepted(JNIEnv* env, jobject obj, float price, int amount, jstring itemName, jstring productID, int startTime, int endTime)
{
    struct paramList
    {
        float productPrice;
        int itemAmount;
        const char* itemName;
        const char* productID;
        int startTime;
        int endTime;
    };
    paramList params;
    params.productPrice = price;
    params.itemAmount = amount;
    params.itemName = s3eEdkGetStringUTF8Chars(itemName);
    params.productID = s3eEdkGetStringUTF8Chars(productID);
    params.startTime = startTime;
    params.endTime = endTime;
    IwTrace(FuseSDK, ("FuseSDKIAPOfferAccepted(%f, %i, %s, %s, %i, %i)", params.productPrice, params.itemAmount, params.itemName, params.productID, params.startTime, params.endTime));
    s3eEdkCallbacksEnqueue(S3E_EXT_FUSESDK_HASH, FUSESDK_IAPOFFER_ACCEPTED, &params, sizeof(paramList));
}
void JNICALL s3eKiip_contentReceivedCallback( JNIEnv* env, jobject obj, jobject param )
{
	s3eDebugOutputString("s3eKiip_contentReceivedCallback: start");

	s3eKiipReceivedContent* pItemData = new s3eKiipReceivedContent();
		
    jclass cls = env->FindClass( "com/s3eKiipExt//MainActivity$ReceivedContent" );
	
	if (env->ExceptionOccurred())
	{
		env->ExceptionDescribe();
		env->ExceptionClear();
	}
	
	pItemData->content			= StringFieldAccessor( env, cls, "content",			param );
	pItemData->quantity			= IntFieldAccessor(    env, cls, "quantity",		param );
	pItemData->transactionID	= StringFieldAccessor( env, cls, "transactionId",	param );
	pItemData->signature		= StringFieldAccessor( env, cls, "signature",		param );

	s3eEdkCallbacksEnqueue(	S3E_EXT_KIIP_HASH, S3EKIIP_CONTENT_RECEIVED, (void*)pItemData, 
		0 , NULL, false, &s3eKiip_ReleaseReceivedContentCallback, (void*)pItemData );
}
Beispiel #26
0
s3eResult s3eDialogAlertBox_platform(s3eDialogAlertInfo* info)
{
    int code = MB_OK;
    if (info->m_Button[2] != NULL && info->m_Button[1] != NULL)
        code = MB_ABORTRETRYIGNORE;
    else if (info->m_Button[1] != NULL)
        code = MB_YESNO;

    s_Info = info;
    s_DialogHook = SetWindowsHookEx(WH_CBT, DialogHookFunction, NULL, GetCurrentThreadId());

    int result = MessageBox(0, info->m_Message, info->m_Title, code);

    s3eDialogCallbackData data;
    data.m_Id = info->m_Id;

    switch(result)
    {
        case IDOK:
        case IDABORT:
        case IDYES:
            data.m_ButtonPressed = 0;
            break;
        case IDRETRY:
        case IDNO:
            data.m_ButtonPressed = 1;
            break;
        case IDIGNORE:
            data.m_ButtonPressed = 2;
            break;
    }

    s3eEdkCallbacksEnqueue(S3E_EXT_DIALOG_HASH, S3E_DIALOG_FINISHED, &data, sizeof(s3eDialogCallbackData));

    // Don't want to persist this pointer value
    s_Info = NULL;

    return S3E_RESULT_SUCCESS;
}
void CallbacksRequestProducts::OnSuccess(const std::vector<OuyaSDK::Product>& products)
{
	//IwTrace(ODK, ("OnSuccess"));

	if (m_products)
	{
		//IwTrace(ODK, ("Cleaning old products"));
		delete [] m_products;
		m_products = NULL;
	}

	if (products.size() > 0)
	{
		//IwTrace(ODK, ("Allocating products"));
		m_products = new OuyaSDK::ExtensionProduct[products.size()];
		//IwTrace(ODK, ("Copying products"));
		for (unsigned int index = 0; index < products.size(); ++index)
		{
			OuyaSDK::Product product = products[index];
			OuyaSDK::ExtensionProduct eProduct;
			eProduct.Init();
			eProduct.Copy(product);
			m_products[index] = eProduct;
		}
	}
	else
	{
		IwTrace(ODK, ("No products to copy"));
	}

	s3eRequestProductsSuccessEvent event;
	event.m_products = m_products;
	event.m_productsLength = products.size();

	IwTrace(ODK, ("Invoking callback"));

	m_dataRequestProductsSuccessEvent = event; //don't send a temp pointer
	s3eEdkCallbacksEnqueue(S3E_EXT_ODK_HASH, S3E_ODK_CALLBACKS_REQUEST_PRODUCTS_ON_SUCCESS, &m_dataRequestProductsSuccessEvent);
}
void JNICALL Heyzap_nativeCallback(JNIEnv* env, jobject obj, jint callbackIndex, jstring callbackData)
{
    const char *callbackDataChars;
    int callbackDataLength;

    if(callbackData == NULL)
    {
        callbackDataChars = NULL;
        callbackDataLength = 0;
    }
    else
    {
        callbackDataChars = env->GetStringUTFChars(callbackData, NULL);
        callbackDataLength = env->GetStringUTFLength(callbackData) + 1; // Include \0
    }
    
    // the callbackIndex sent in Heyzap.java is the ordinal from the same enum used for the callbacks in C here
    s3eEdkCallbacksEnqueue(S3E_EXT_HEYZAP_HASH, (HeyzapCallback)callbackIndex, (void  *)callbackDataChars, callbackDataLength);

    if(callbackData != NULL)
    {
        env->ReleaseStringUTFChars(callbackData, callbackDataChars);
    }
}
void native_notifyClosed(JNIEnv * env, jobject obj){
    s3eEdkCallbacksEnqueue(S3E_EXT_CGPOLLFISH_HASH, CGPOLLFISH_CALLBACK_CLOSED);
}
void native_notifyNotEligible(JNIEnv * env, jobject obj){
    s3eEdkCallbacksEnqueue(S3E_EXT_CGPOLLFISH_HASH, CGPOLLFISH_CALLBACK_NOTELIGIBLE);
}