refactor/extension #1
17
.vscode/c_cpp_properties.json
vendored
Normal file
17
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/home/nick/Workspace/defold/engine/**",
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "gnu++17",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
@ -1,5 +1,10 @@
|
|||||||
#if defined(DM_PLATFORM_ANDROID)
|
#if defined(DM_PLATFORM_ANDROID)
|
||||||
|
|
||||||
|
#define EXTENSION_NAME IAPExt
|
||||||
|
#define LIB_NAME "IAPExt"
|
||||||
|
#define MODULE_NAME "IAPExt"
|
||||||
|
#define DLIB_LOG_DOMAIN LIB_NAME
|
||||||
|
|
||||||
#include <dmsdk/sdk.h>
|
#include <dmsdk/sdk.h>
|
||||||
#include <dmsdk/dlib/android.h>
|
#include <dmsdk/dlib/android.h>
|
||||||
|
|
||||||
@ -8,8 +13,6 @@
|
|||||||
#include "iap.h"
|
#include "iap.h"
|
||||||
#include "iap_private.h"
|
#include "iap_private.h"
|
||||||
|
|
||||||
#define LIB_NAME "iap"
|
|
||||||
|
|
||||||
struct IAP
|
struct IAP
|
||||||
{
|
{
|
||||||
IAP()
|
IAP()
|
||||||
@ -267,6 +270,7 @@ JNIEXPORT void JNICALL Java_com_defold_iap_IapJNI_onProductsResult(JNIEnv* env,
|
|||||||
cmd->m_Data = strdup(pl);
|
cmd->m_Data = strdup(pl);
|
||||||
env->ReleaseStringUTFChars(productList, pl);
|
env->ReleaseStringUTFChars(productList, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
IAP_Queue_Push(&g_IAP.m_CommandQueue, cmd);
|
IAP_Queue_Push(&g_IAP.m_CommandQueue, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +292,7 @@ JNIEXPORT void JNICALL Java_com_defold_iap_IapJNI_onPurchaseResult__ILjava_lang_
|
|||||||
cmd.m_Data = strdup(pd);
|
cmd.m_Data = strdup(pd);
|
||||||
env->ReleaseStringUTFChars(purchaseData, pd);
|
env->ReleaseStringUTFChars(purchaseData, pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
IAP_Queue_Push(&g_IAP.m_CommandQueue, &cmd);
|
IAP_Queue_Push(&g_IAP.m_CommandQueue, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +348,7 @@ static void HandlePurchaseResult(const IAPCommand* cmd)
|
|||||||
|
|
||||||
if (!dmScript::SetupCallback(cmd->m_Callback))
|
if (!dmScript::SetupCallback(cmd->m_Callback))
|
||||||
{
|
{
|
||||||
|
dmLogError("Failed to setup callback");
|
||||||
assert(top == lua_gettop(L));
|
assert(top == lua_gettop(L));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -358,6 +364,7 @@ static void HandlePurchaseResult(const IAPCommand* cmd)
|
|||||||
IAP_PushError(L, "purchase response was null", REASON_UNSPECIFIED);
|
IAP_PushError(L, "purchase response was null", REASON_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
} else if (cmd->m_ResponseCode == BILLING_RESPONSE_RESULT_USER_CANCELED) {
|
} else if (cmd->m_ResponseCode == BILLING_RESPONSE_RESULT_USER_CANCELED) {
|
||||||
|
dmLogError("User canceled purchase");
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
IAP_PushError(L, "user canceled purchase", REASON_USER_CANCELED);
|
IAP_PushError(L, "user canceled purchase", REASON_USER_CANCELED);
|
||||||
} else {
|
} else {
|
||||||
@ -367,9 +374,7 @@ static void HandlePurchaseResult(const IAPCommand* cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dmScript::PCall(L, 3, 0);
|
dmScript::PCall(L, 3, 0);
|
||||||
|
|
||||||
dmScript::TeardownCallback(cmd->m_Callback);
|
dmScript::TeardownCallback(cmd->m_Callback);
|
||||||
|
|
||||||
assert(top == lua_gettop(L));
|
assert(top == lua_gettop(L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,9 +459,10 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
|||||||
env->DeleteGlobalRef(g_IAP.m_IAP);
|
env->DeleteGlobalRef(g_IAP.m_IAP);
|
||||||
env->DeleteGlobalRef(g_IAP.m_IAPJNI);
|
env->DeleteGlobalRef(g_IAP.m_IAPJNI);
|
||||||
g_IAP.m_IAP = NULL;
|
g_IAP.m_IAP = NULL;
|
||||||
|
|
||||||
return dmExtension::RESULT_OK;
|
return dmExtension::RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DM_DECLARE_EXTENSION(IAPExt, "IAP", 0, 0, InitializeIAP, UpdateIAP, 0, FinalizeIAP)
|
DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, 0, 0, InitializeIAP, UpdateIAP, 0, FinalizeIAP)
|
||||||
|
|
||||||
#endif //DM_PLATFORM_ANDROID
|
#endif //DM_PLATFORM_ANDROID
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#if defined(DM_PLATFORM_IOS)
|
#if defined(DM_PLATFORM_IOS)
|
||||||
|
|
||||||
|
#define EXTENSION_NAME IAPExt
|
||||||
|
#define LIB_NAME "IAPExt"
|
||||||
|
#define MODULE_NAME "IAPExt"
|
||||||
|
#define DLIB_LOG_DOMAIN LIB_NAME
|
||||||
|
|
||||||
#include <dmsdk/sdk.h>
|
#include <dmsdk/sdk.h>
|
||||||
|
|
||||||
#include "iap.h"
|
#include "iap.h"
|
||||||
@ -9,8 +14,6 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <StoreKit/StoreKit.h>
|
#import <StoreKit/StoreKit.h>
|
||||||
|
|
||||||
#define LIB_NAME "iap"
|
|
||||||
|
|
||||||
struct IAP;
|
struct IAP;
|
||||||
|
|
||||||
@interface SKPaymentTransactionObserver : NSObject<SKPaymentTransactionObserver>
|
@interface SKPaymentTransactionObserver : NSObject<SKPaymentTransactionObserver>
|
||||||
@ -636,6 +639,5 @@ static dmExtension::Result FinalizeIAP(dmExtension::Params* params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DM_DECLARE_EXTENSION(IAPExt, "IAP", 0, 0, InitializeIAP, UpdateIAP, 0, FinalizeIAP)
|
DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, 0, 0, InitializeIAP, UpdateIAP, 0, FinalizeIAP)
|
||||||
|
|
||||||
#endif // DM_PLATFORM_IOS
|
#endif // DM_PLATFORM_IOS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user