the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "SonyCommerce_Orbis.h"
4#include "PS3\PS3Extras\ShutdownManager.h"
5#include <sys/event.h>
6
7
8bool SonyCommerce_Orbis::m_bCommerceInitialised = false;
9// SceNpCommerce2SessionInfo SonyCommerce_Orbis::m_sessionInfo;
10SonyCommerce_Orbis::State SonyCommerce_Orbis::m_state = e_state_noSession;
11int SonyCommerce_Orbis::m_errorCode = 0;
12LPVOID SonyCommerce_Orbis::m_callbackParam = NULL;
13
14void* SonyCommerce_Orbis::m_receiveBuffer = NULL;
15SonyCommerce_Orbis::Event SonyCommerce_Orbis::m_event;
16std::queue<SonyCommerce_Orbis::Message> SonyCommerce_Orbis::m_messageQueue;
17std::vector<SonyCommerce_Orbis::ProductInfo>* SonyCommerce_Orbis::m_pProductInfoList = NULL;
18SonyCommerce_Orbis::ProductInfoDetailed* SonyCommerce_Orbis::m_pProductInfoDetailed = NULL;
19SonyCommerce_Orbis::ProductInfo* SonyCommerce_Orbis::m_pProductInfo = NULL;
20
21SonyCommerce_Orbis::CategoryInfo* SonyCommerce_Orbis::m_pCategoryInfo = NULL;
22const char* SonyCommerce_Orbis::m_pProductID = NULL;
23char* SonyCommerce_Orbis::m_pCategoryID = NULL;
24SonyCommerce_Orbis::CheckoutInputParams SonyCommerce_Orbis::m_checkoutInputParams;
25SonyCommerce_Orbis::DownloadListInputParams SonyCommerce_Orbis::m_downloadInputParams;
26
27SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_callbackFunc = NULL;
28// sys_memory_container_t SonyCommerce_Orbis::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID;
29bool SonyCommerce_Orbis::m_bUpgradingTrial = false;
30
31SonyCommerce_Orbis::CallbackFunc SonyCommerce_Orbis::m_trialUpgradeCallbackFunc;
32LPVOID SonyCommerce_Orbis::m_trialUpgradeCallbackParam;
33
34CRITICAL_SECTION SonyCommerce_Orbis::m_queueLock;
35
36uint32_t SonyCommerce_Orbis::m_contextId=0; ///< The npcommerce2 context ID
37bool SonyCommerce_Orbis::m_contextCreated=false; ///< npcommerce2 context ID created?
38SonyCommerce_Orbis::Phase SonyCommerce_Orbis::m_currentPhase = e_phase_stopped; ///< Current commerce2 util
39// char SonyCommerce_Orbis::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE];
40
41C4JThread* SonyCommerce_Orbis::m_tickThread = NULL;
42bool SonyCommerce_Orbis::m_bLicenseChecked=false; // Check the trial/full license for the game
43
44
45
46
47sce::Toolkit::NP::Utilities::Future<std::vector<sce::Toolkit::NP::ProductInfo> > g_productList;
48sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::CategoryInfo> g_categoryInfo;
49sce::Toolkit::NP::Utilities::Future<sce::Toolkit::NP::ProductInfoDetailed> g_detailedProductInfo;
50
51
52SonyCommerce_Orbis::ProductInfoDetailed s_trialUpgradeProductInfoDetailed;
53void SonyCommerce_Orbis::Delete()
54{
55 m_pProductInfoList=NULL;
56 m_pProductInfoDetailed=NULL;
57 m_pProductInfo=NULL;
58 m_pCategoryInfo = NULL;
59 m_pProductID = NULL;
60 m_pCategoryID = NULL;
61}
62
63void SonyCommerce_Orbis::Init()
64{
65 assert(m_state == e_state_noSession);
66 if(!m_bCommerceInitialised)
67 {
68 m_bCommerceInitialised = true;
69 m_pCategoryID=(char *)malloc(sizeof(char) * 100);
70 InitializeCriticalSection(&m_queueLock);
71 }
72}
73
74
75
76void SonyCommerce_Orbis::CheckForTrialUpgradeKey_Callback(LPVOID param, bool bFullVersion)
77{
78 ProfileManager.SetFullVersion(bFullVersion);
79 if(ProfileManager.IsFullVersion())
80 {
81 StorageManager.SetSaveDisabled(false);
82 ConsoleUIController::handleUnlockFullVersionCallback();
83 // licence has been checked, so we're ok to install the trophies now
84// ProfileManager.InitialiseTrophies( SQRNetworkManager_Orbis::GetSceNpCommsId(),
85// SQRNetworkManager_Orbis::GetSceNpCommsSig());
86//
87 }
88 m_bLicenseChecked=true;
89}
90
91bool SonyCommerce_Orbis::LicenseChecked()
92{
93 return m_bLicenseChecked;
94}
95
96void SonyCommerce_Orbis::CheckForTrialUpgradeKey()
97{
98 StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL);
99}
100
101int SonyCommerce_Orbis::Shutdown()
102{
103 int ret=0;
104 m_bCommerceInitialised = false;
105 if (m_contextCreated)
106 {
107 m_contextId = 0;
108 m_contextCreated = false;
109 }
110
111 delete m_pCategoryID;
112 DeleteCriticalSection(&m_queueLock);
113
114 // clear any possible callback function
115 m_callbackFunc = NULL;
116
117 return ret;
118}
119
120
121
122int SonyCommerce_Orbis::TickLoop(void* lpParam)
123{
124 ShutdownManager::HasStarted(ShutdownManager::eCommerceThread);
125 while( (m_currentPhase != e_phase_stopped) && ShutdownManager::ShouldRun(ShutdownManager::eCommerceThread) )
126 {
127 processEvent();
128 processMessage();
129 Sleep(16); // sleep for a frame
130// ((SonyCommerce_Orbis*)app.GetCommerce())->Test();
131 }
132
133 Shutdown();
134 ShutdownManager::HasFinished(ShutdownManager::eCommerceThread);
135
136 return 0;
137}
138
139void SonyCommerce_Orbis::copyProductList(std::vector<ProductInfo>* pProductList, std::vector<sce::Toolkit::NP::ProductInfo>* pNPProductList)
140{
141 ProductInfo tempInfo;
142 std::vector<ProductInfo> tempProductVec;
143 // Reserve some space
144 int numProducts = pNPProductList->size();
145 tempProductVec.reserve(numProducts);
146 for(int i=0;i<numProducts;i++)
147 {
148 sce::Toolkit::NP::ProductInfo& npInfo = pNPProductList->at(i);
149
150 // reset tempInfo
151 memset(&tempInfo, 0x0, sizeof(tempInfo));
152 strncpy(tempInfo.productId, npInfo.productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN);
153 strncpy(tempInfo.productName, npInfo.productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN);
154 strncpy(tempInfo.shortDescription, npInfo.shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN);
155 strcpy(tempInfo.longDescription,"Missing long description");
156 strncpy(tempInfo.spName, npInfo.spName, SCE_NP_COMMERCE2_SP_NAME_LEN);
157 strncpy(tempInfo.imageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN);
158 tempInfo.releaseDate = npInfo.releaseDate;
159 tempInfo.purchasabilityFlag = npInfo.purchasabilityFlag;
160 // Take out the price. Nicely formatted
161 // but also keep the price as a value in case it's 0 - we need to show "free" for that
162 tempInfo.ui32Price = -1;// not available here
163 strncpy(tempInfo.price, npInfo.price, SCE_TOOLKIT_NP_SKU_PRICE_LEN);
164 tempProductVec.push_back(tempInfo);
165 }
166 pNPProductList->clear(); // clear the vector now we're done, this doesn't happen automatically for the next query
167
168 // Set our result
169 *pProductList = tempProductVec;
170}
171
172int SonyCommerce_Orbis::getProductList(std::vector<ProductInfo>* productList, char *categoryId)
173{
174 int ret;
175 sce::Toolkit::NP::ProductListInputParams params;
176 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
177
178 params.userInfo.userId = userId;
179 strcpy(params.categoryId, categoryId);
180 params.serviceLabel = 0;
181 app.DebugPrintf("Getting Product List ...\n");
182
183 ret = sce::Toolkit::NP::Commerce::Interface::getProductList(&g_productList, params, true);
184 if (ret < 0)
185 {
186 app.DebugPrintf("CommerceInterface::getProductList() error. ret = 0x%x\n", ret);
187 return ret;
188 }
189
190 if (g_productList.hasResult())
191 {
192 // result has returned immediately (don't think this should happen, but was handled in the samples
193 copyProductList(productList, g_productList.get());
194 m_event = e_event_commerceGotProductList;
195 }
196
197 return ret;
198}
199
200
201
202void SonyCommerce_Orbis::copyCategoryInfo(CategoryInfo *pInfo, sce::Toolkit::NP::CategoryInfo *pNPInfo)
203{
204 strcpy(pInfo->current.categoryId, pNPInfo->current.categoryId);
205 strcpy(pInfo->current.categoryName, pNPInfo->current.categoryName);
206 strcpy(pInfo->current.categoryDescription, pNPInfo->current.categoryDescription);
207 strcpy(pInfo->current.imageUrl, pNPInfo->current.imageUrl);
208 pInfo->countOfProducts = pNPInfo->countOfProducts;
209 pInfo->countOfSubCategories = pNPInfo->countOfSubCategories;
210 if(pInfo->countOfSubCategories > 0)
211 {
212 std::list<sce::Toolkit::NP::CategoryInfoSub>::iterator iter = pNPInfo->subCategories.begin();
213 std::list<sce::Toolkit::NP::CategoryInfoSub>::iterator iterEnd = pNPInfo->subCategories.end();
214
215 while(iter != iterEnd)
216 {
217 // For each sub category, obtain information
218 CategoryInfoSub tempSubCatInfo;
219 strcpy(tempSubCatInfo.categoryId, iter->categoryId);
220 strcpy(tempSubCatInfo.categoryName, iter->categoryName);
221 strcpy(tempSubCatInfo.categoryDescription, iter->categoryDescription);
222 strcpy(tempSubCatInfo.imageUrl, iter->imageUrl);
223 // Add to the list
224 pInfo->subCategories.push_back(tempSubCatInfo);
225 iter++;
226 }
227 }
228}
229
230int SonyCommerce_Orbis::getCategoryInfo(CategoryInfo *pInfo, char *categoryId)
231{
232
233
234 int ret;
235 sce::Toolkit::NP::CategoryInfoInputParams params;
236 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
237
238 params.userInfo.userId = userId;
239 strcpy(params.categoryId, "");//categoryId);
240 params.serviceLabel = 0;
241
242 app.DebugPrintf("Getting Category Information...\n");
243
244 ret = sce::Toolkit::NP::Commerce::Interface::getCategoryInfo(&g_categoryInfo, params, true);
245 if (ret < 0)
246 {
247 // error
248 app.DebugPrintf("Commerce::Interface::getCategoryInfo error: 0x%x\n", ret);
249 return ret;
250 }
251 else if (g_categoryInfo.hasResult())
252 {
253 // result has returned immediately (don't think this should happen, but was handled in the samples
254 copyCategoryInfo(pInfo, g_categoryInfo.get());
255 m_event = e_event_commerceGotCategoryInfo;
256 }
257
258 return ret;
259}
260
261void SonyCommerce_Orbis::copyDetailedProductInfo(ProductInfoDetailed *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo)
262{
263 // populate our temp struct
264 // pInfo->ratingDescriptors = npInfo.ratingSystemId;
265 strncpy(pInfo->productId, pNPInfo->productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN);
266 strncpy(pInfo->productName, pNPInfo->productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN);
267 strncpy(pInfo->shortDescription, pNPInfo->shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN);
268 strncpy(pInfo->longDescription, pNPInfo->longDescription, SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN);
269 strncpy(pInfo->legalDescription, pNPInfo->legalDescription, SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN);
270 strncpy(pInfo->spName, pNPInfo->spName, SCE_NP_COMMERCE2_SP_NAME_LEN);
271 strncpy(pInfo->imageUrl, pNPInfo->imageUrl, SCE_NP_COMMERCE2_URL_LEN);
272 pInfo->releaseDate = pNPInfo->releaseDate;
273 strncpy(pInfo->ratingSystemId, pNPInfo->ratingSystemId, SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN);
274 strncpy(pInfo->ratingImageUrl, pNPInfo->imageUrl, SCE_NP_COMMERCE2_URL_LEN);
275 strncpy(pInfo->skuId, pNPInfo->skuId, SCE_NP_COMMERCE2_SKU_ID_LEN);
276 pInfo->purchasabilityFlag = pNPInfo->purchasabilityFlag;
277 pInfo->ui32Price= pNPInfo->intPrice;
278 strncpy(pInfo->price, pNPInfo->price, SCE_TOOLKIT_NP_SKU_PRICE_LEN);
279
280}
281int SonyCommerce_Orbis::getDetailedProductInfo(ProductInfoDetailed *pInfo, const char *productId, char *categoryId)
282{
283 int ret;
284 sce::Toolkit::NP::DetailedProductInfoInputParams params;
285 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
286
287 params.userInfo.userId = userId;
288 strcpy(params.categoryId, categoryId);
289 strcpy(params.productId, productId);
290
291
292 app.DebugPrintf("Getting Detailed Product Information ... \n");
293 ret = sce::Toolkit::NP::Commerce::Interface::getDetailedProductInfo(&g_detailedProductInfo, params, true);
294 if (ret < 0)
295 {
296 app.DebugPrintf("CommerceInterface::getDetailedProductInfo() error. ret = 0x%x\n", ret);
297 return ret;
298 }
299
300 if (g_detailedProductInfo.hasResult())
301 {
302 // result has returned immediately (don't think this should happen, but was handled in the samples
303 copyDetailedProductInfo(pInfo, g_detailedProductInfo.get());
304 m_event = e_event_commerceGotDetailedProductInfo;
305 }
306 return ret;
307}
308
309void SonyCommerce_Orbis::copyAddDetailedProductInfo(ProductInfo *pInfo, sce::Toolkit::NP::ProductInfoDetailed* pNPInfo)
310{
311
312 // populate our temp struct
313 // pInfo->ratingDescriptors = npInfo.ratingSystemId;
314 // strncpy(pInfo->productId, npInfo.productId, SCE_NP_COMMERCE2_PRODUCT_ID_LEN);
315 // strncpy(pInfo->productName, npInfo.productName, SCE_NP_COMMERCE2_PRODUCT_NAME_LEN);
316 // strncpy(pInfo->shortDescription, npInfo.shortDescription, SCE_NP_COMMERCE2_PRODUCT_SHORT_DESCRIPTION_LEN);
317 strncpy(pInfo->longDescription, pNPInfo->longDescription, SCE_NP_COMMERCE2_PRODUCT_LONG_DESCRIPTION_LEN);
318 // strncpy(pInfo->legalDescription, npInfo.legalDescription, SCE_NP_COMMERCE2_PRODUCT_LEGAL_DESCRIPTION_LEN);
319 // strncpy(pInfo->spName, npInfo.spName, SCE_NP_COMMERCE2_SP_NAME_LEN);
320 // strncpy(pInfo->imageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN);
321 // pInfo->releaseDate = npInfo.releaseDate;
322 // strncpy(pInfo->ratingSystemId, npInfo.ratingSystemId, SCE_NP_COMMERCE2_RATING_SYSTEM_ID_LEN);
323 // strncpy(pInfo->ratingImageUrl, npInfo.imageUrl, SCE_NP_COMMERCE2_URL_LEN);
324 strncpy(pInfo->skuId, pNPInfo->skuId, SCE_NP_COMMERCE2_SKU_ID_LEN);
325 pInfo->purchasabilityFlag = pNPInfo->purchasabilityFlag;
326 pInfo->ui32Price= pNPInfo->intPrice;
327 strncpy(pInfo->price, pNPInfo->price, SCE_TOOLKIT_NP_SKU_PRICE_LEN);
328
329}
330
331int SonyCommerce_Orbis::addDetailedProductInfo(ProductInfo *pInfo, const char *productId, char *categoryId)
332{
333 int ret;
334 sce::Toolkit::NP::DetailedProductInfoInputParams params;
335 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
336
337 params.userInfo.userId = userId;
338 strcpy(params.categoryId, categoryId);
339 strcpy(params.productId, productId);
340
341
342 app.DebugPrintf("Getting Detailed Product Information ... \n");
343 ret = sce::Toolkit::NP::Commerce::Interface::getDetailedProductInfo(&g_detailedProductInfo, params, true);
344 if (ret < 0)
345 {
346 app.DebugPrintf("CommerceInterface::addDetailedProductInfo() error. ret = 0x%x\n", ret);
347 }
348
349 if (g_detailedProductInfo.hasResult())
350 {
351 // result has returned immediately (don't think this should happen, but was handled in the samples
352 copyAddDetailedProductInfo(pInfo, g_detailedProductInfo.get());
353 m_event = e_event_commerceAddedDetailedProductInfo;
354 }
355 return ret;
356}
357
358
359int SonyCommerce_Orbis::checkout(CheckoutInputParams ¶ms)
360{
361
362 int ret;
363 sce::Toolkit::NP::CheckoutInputParams npParams;
364 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
365 npParams.userInfo.userId = userId;
366 npParams.serviceLabel = 0;
367
368 std::list<const char*>::iterator iter = params.skuIds.begin();
369 std::list<const char*>::iterator iterEnd = params.skuIds.end();
370 while(iter != iterEnd)
371 {
372 npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const
373 iter++;
374 }
375
376 app.DebugPrintf("Starting Checkout...\n");
377
378 ret = sce::Toolkit::NP::Commerce::Interface::checkout(npParams, false);
379 if (ret < 0)
380 {
381 app.DebugPrintf("Sample menu checkout() error. ret = 0x%x\n", ret);
382 }
383
384
385 return ret;
386}
387
388
389int SonyCommerce_Orbis::downloadList(DownloadListInputParams ¶ms)
390{
391
392 int ret;
393 sce::Toolkit::NP::DownloadListInputParams npParams;
394 //memset(&npParams,0,sizeof(sce::Toolkit::NP::DownloadListInputParams));
395 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
396 npParams.userInfo.userId = userId;
397 npParams.serviceLabel = 0;
398 npParams.skuIds.clear();
399
400 std::list<const char*>::iterator iter = params.skuIds.begin();
401 std::list<const char*>::iterator iterEnd = params.skuIds.end();
402 while(iter != iterEnd)
403 {
404 npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const
405 iter++;
406 }
407
408 app.DebugPrintf("Starting Store Download List...\n");
409 ret = sce::Toolkit::NP::Commerce::Interface::displayDownloadList(npParams, true);
410 if (ret < 0)
411 {
412 app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret);
413 }
414
415 return ret;
416}
417
418int SonyCommerce_Orbis::checkout_game(CheckoutInputParams ¶ms)
419{
420
421 int ret;
422 sce::Toolkit::NP::CheckoutInputParams npParams;
423 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
424 npParams.userInfo.userId = userId;
425 npParams.serviceLabel = 0;
426
427 std::list<const char*>::iterator iter = params.skuIds.begin();
428 std::list<const char*>::iterator iterEnd = params.skuIds.end();
429 while(iter != iterEnd)
430 {
431 npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const
432 iter++;
433 }
434
435 app.DebugPrintf("Starting Checkout...\n");
436 sce::Toolkit::NP::ProductBrowseParams Myparams;
437
438 Myparams.serviceLabel = 0;
439 Myparams.userInfo.userId = userId;
440 strncpy(Myparams.productId, "MINECRAFTPS40000", strlen("MINECRAFTPS40000"));
441
442 ret = sce::Toolkit::NP::Commerce::Interface::productBrowse(Myparams, false);
443 if (ret < 0) {
444 // Error handling
445 }
446
447
448 //ret = sce::Toolkit::NP::Commerce::Interface::checkout(npParams, false);
449 if (ret < 0)
450 {
451 app.DebugPrintf("Sample menu checkout() error. ret = 0x%x\n", ret);
452 }
453
454
455 return ret;
456}
457
458int SonyCommerce_Orbis::downloadList_game(DownloadListInputParams ¶ms)
459{
460
461 int ret;
462 sce::Toolkit::NP::DownloadListInputParams npParams;
463 //memset(&npParams,0,sizeof(sce::Toolkit::NP::DownloadListInputParams));
464 SceUserServiceUserId userId = ProfileManager.getUserID(ProfileManager.GetPrimaryPad());
465 npParams.userInfo.userId = userId;
466 npParams.serviceLabel = 0;
467 npParams.skuIds.clear();
468
469 std::list<const char*>::iterator iter = params.skuIds.begin();
470 std::list<const char*>::iterator iterEnd = params.skuIds.end();
471 while(iter != iterEnd)
472 {
473 npParams.skuIds.push_back((char*)*iter); // have to remove the const here, not sure why the libs pointers aren't const
474 iter++;
475 }
476
477 app.DebugPrintf("Starting Store Download List...\n");
478// ret = sce::Toolkit::NP::Commerce::Interface::displayDownloadList(npParams, true);
479// if (ret < 0)
480// {
481// app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret);
482// }
483
484 sce::Toolkit::NP::ProductBrowseParams Myparams;
485
486 Myparams.serviceLabel = 0;
487 Myparams.userInfo.userId = userId;
488 strncpy(Myparams.productId, "MINECRAFTPS40000", strlen("MINECRAFTPS40000"));
489
490 ret = sce::Toolkit::NP::Commerce::Interface::productBrowse(Myparams, false);
491 if (ret < 0) {
492 // Error handling
493 app.DebugPrintf("Commerce::Interface::displayDownloadList error: 0x%x\n", ret);
494 }
495
496
497
498 return ret;
499}
500
501void SonyCommerce_Orbis::UpgradeTrialCallback2(LPVOID lpParam,int err)
502{
503 SonyCommerce* pCommerce = (SonyCommerce*)lpParam;
504 app.DebugPrintf(4,"SonyCommerce_UpgradeTrialCallback2 : err : 0x%08x\n", err);
505 pCommerce->CheckForTrialUpgradeKey();
506 if(err != SCE_OK)
507 {
508 UINT uiIDA[1];
509 uiIDA[0]=IDS_CONFIRM_OK;
510 C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad());
511 }
512 m_trialUpgradeCallbackFunc(m_trialUpgradeCallbackParam, m_errorCode);
513}
514
515void SonyCommerce_Orbis::UpgradeTrialCallback1(LPVOID lpParam,int err)
516{
517 SonyCommerce* pCommerce = (SonyCommerce*)lpParam;
518 app.DebugPrintf(4,"SonyCommerce_UpgradeTrialCallback1 : err : 0x%08x\n", err);
519 if(err == SCE_OK)
520 {
521 char* skuID = s_trialUpgradeProductInfoDetailed.skuId;
522 if(s_trialUpgradeProductInfoDetailed.purchasabilityFlag == SCE_TOOLKIT_NP_COMMERCE_NOT_PURCHASED)
523 {
524 app.DebugPrintf(4,"UpgradeTrialCallback1 - Checkout\n");
525 pCommerce->Checkout_Game(UpgradeTrialCallback2, pCommerce, skuID);
526
527
528
529 }
530 else
531 {
532 app.DebugPrintf(4,"UpgradeTrialCallback1 - DownloadAlreadyPurchased\n");
533 pCommerce->DownloadAlreadyPurchased_Game(UpgradeTrialCallback2, pCommerce, skuID);
534 }
535 }
536 else
537 {
538 UINT uiIDA[1];
539 uiIDA[0]=IDS_CONFIRM_OK;
540 C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PRO_UNLOCKGAME_TITLE, IDS_NO_DLCOFFERS, uiIDA,1,ProfileManager.GetPrimaryPad());
541 m_trialUpgradeCallbackFunc(m_trialUpgradeCallbackParam, m_errorCode);
542 }
543}
544
545
546
547// global func, so we can call from the profile lib
548void SonyCommerce_UpgradeTrial()
549{
550 // we're now calling the app function here, which manages pending requests
551 app.UpgradeTrial();
552}
553
554void SonyCommerce_Orbis::UpgradeTrial(CallbackFunc cb, LPVOID lpParam)
555{
556 m_trialUpgradeCallbackFunc = cb;
557 m_trialUpgradeCallbackParam = lpParam;
558
559// static char szTrialUpgradeSkuID[64];
560// sprintf(szTrialUpgradeSkuID, "%s-TRIALUPGRADE0001", app.GetCommerceCategory());//, szSKUSuffix);
561 GetDetailedProductInfo(UpgradeTrialCallback1, this, &s_trialUpgradeProductInfoDetailed, app.GetUpgradeKey(), app.GetCommerceCategory());
562}
563
564
565int SonyCommerce_Orbis::createContext()
566{
567// SceNpId npId;
568// int ret = sceNpManagerGetNpId(&npId);
569// if(ret < 0)
570// {
571// app.DebugPrintf(4,"createContext sceNpManagerGetNpId problem\n");
572// return ret;
573// }
574//
575// if (m_contextCreated) {
576// ret = sceNpCommerce2DestroyCtx(m_contextId);
577// if (ret < 0)
578// {
579// app.DebugPrintf(4,"createContext sceNpCommerce2DestroyCtx problem\n");
580// return ret;
581// }
582// }
583//
584// // Create commerce2 context
585// ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId);
586// if (ret < 0)
587// {
588// app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n");
589// return ret;
590// }
591
592 m_contextCreated = true;
593
594 return SCE_OK;
595}
596
597int SonyCommerce_Orbis::createSession()
598{
599 // From the Sony docs
600 //
601 // sce::Toolkit::NP::Commerce::Interface::CreateSession
602 //
603 // This function is provided to maintain compatibility with the PlayStation�Vita and PlayStation�3 platforms. Because commerce on the PlayStation�4 is not session based, SCE_TOOLKIT_NP_SUCCESS is always returned.
604
605 int ret = sce::Toolkit::NP::Commerce::Interface::createSession();
606
607 if (ret < 0)
608 {
609 return ret;
610 }
611 m_currentPhase = e_phase_creatingSessionPhase;
612
613 return ret;
614}
615
616
617void SonyCommerce_Orbis::commerce2Handler( const sce::Toolkit::NP::Event& event)
618{
619// Event reply;
620// reply.service = Toolkit::NP::commerce;
621//
622 if(m_bCommerceInitialised==false)
623 {
624 // 4J-PB - this happens when we've signed out of the PSn, and we were in the process of retrieving DLC product info
625 // Ignore this event
626 app.DebugPrintf("@@@@@@@@ IGNORING COMMERCE EVENT AFTER COMMERCE SHUTDOWN @@@@@@@@@\n");
627 return;
628 }
629 EnterCriticalSection(&m_queueLock);
630
631 switch (event.event)
632 {
633 case sce::Toolkit::NP::Event::UserEvent::commerceError:
634 {
635 m_messageQueue.push(e_message_commerceEnd);
636 m_errorCode = event.returnCode;
637 break;
638 }
639 case sce::Toolkit::NP::Event::UserEvent::commerceSessionCreated:
640 {
641 m_messageQueue.push(e_message_commerceEnd);
642 m_event = e_event_commerceSessionCreated;
643 break;
644 }
645 case sce::Toolkit::NP::Event::UserEvent::commerceSessionAborted:
646 {
647 m_messageQueue.push(e_message_commerceEnd);
648 m_event = e_event_commerceSessionAborted;
649 break;
650 }
651 case sce::Toolkit::NP::Event::UserEvent::commerceCheckoutStarted:
652 {
653 m_currentPhase = e_phase_checkoutPhase;
654 m_event = e_event_commerceCheckoutStarted;
655 break;
656 }
657 case sce::Toolkit::NP::Event::UserEvent::commerceGotCategoryInfo:
658 {
659 copyCategoryInfo(m_pCategoryInfo, g_categoryInfo.get());
660 m_pCategoryInfo = NULL;
661 m_event = e_event_commerceGotCategoryInfo;
662 break;
663 }
664
665 case sce::Toolkit::NP::Event::UserEvent::commerceGotProductList:
666 {
667 copyProductList(m_pProductInfoList, g_productList.get());
668 m_pProductInfoDetailed = NULL;
669 m_event = e_event_commerceGotProductList;
670 break;
671 }
672
673 case sce::Toolkit::NP::Event::UserEvent::commerceGotDetailedProductInfo:
674 {
675 if(m_pProductInfoDetailed)
676 {
677 copyDetailedProductInfo(m_pProductInfoDetailed, g_detailedProductInfo.get());
678 m_pProductInfoDetailed = NULL;
679 }
680 else
681 {
682 copyAddDetailedProductInfo(m_pProductInfo, g_detailedProductInfo.get());
683 m_pProductInfo = NULL;
684 }
685 m_event = e_event_commerceGotDetailedProductInfo;
686 break;
687 }
688
689
690
691// case SCE_NP_COMMERCE2_EVENT_DO_CHECKOUT_SUCCESS:
692// {
693// m_messageQueue.push(e_message_commerceEnd);
694// m_event = e_event_commerceCheckoutSuccess;
695// break;
696// }
697// case SCE_NP_COMMERCE2_EVENT_DO_CHECKOUT_BACK:
698// {
699// m_messageQueue.push(e_message_commerceEnd);
700// m_event = e_event_commerceCheckoutAborted;
701// break;
702// }
703 case sce::Toolkit::NP::Event::UserEvent::commerceCheckoutFinished:
704 {
705 m_event = e_event_commerceCheckoutFinished;
706 break;
707 }
708 case sce::Toolkit::NP::Event::UserEvent::commerceDownloadListStarted:
709 {
710 m_currentPhase = e_phase_downloadListPhase;
711 m_event = e_event_commerceDownloadListStarted;
712 break;
713 }
714// case SCE_NP_COMMERCE2_EVENT_DO_DL_LIST_SUCCESS:
715// {
716// m_messageQueue.push(e_message_commerceEnd);
717// m_event = e_event_commerceDownloadListSuccess;
718// break;
719// }
720 case sce::Toolkit::NP::Event::UserEvent::commerceDownloadListFinished:
721 {
722 m_event = e_event_commerceDownloadListFinished;
723 break;
724 }
725
726 case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseStarted:
727 {
728 m_currentPhase = e_phase_productBrowsePhase;
729 m_event = e_event_commerceProductBrowseStarted;
730 break;
731 }
732 case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseSuccess:
733 {
734 m_messageQueue.push(e_message_commerceEnd);
735 m_event = e_event_commerceProductBrowseSuccess;
736 break;
737 }
738 case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseAborted:
739 {
740 m_messageQueue.push(e_message_commerceEnd);
741 m_event = e_event_commerceProductBrowseAborted;
742 break;
743 }
744 case sce::Toolkit::NP::Event::UserEvent::commerceProductBrowseFinished:
745 {
746 m_event = e_event_commerceProductBrowseFinished;
747 break;
748 }
749
750// case SCE_NP_COMMERCE2_EVENT_DO_PROD_BROWSE_OPENED:
751// break;
752// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_STARTED:
753// {
754// m_currentPhase = e_phase_voucherRedeemPhase;
755// m_event = e_event_commerceVoucherInputStarted;
756// break;
757// }
758// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_SUCCESS:
759// {
760// m_messageQueue.push(e_message_commerceEnd);
761// m_event = e_event_commerceVoucherInputSuccess;
762// break;
763// }
764// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_BACK:
765// {
766// m_messageQueue.push(e_message_commerceEnd);
767// m_event = e_event_commerceVoucherInputAborted;
768// break;
769// }
770// case SCE_NP_COMMERCE2_EVENT_DO_PRODUCT_CODE_FINISHED:
771// {
772// m_event = e_event_commerceVoucherInputFinished;
773// break;
774// }
775 default:
776 break;
777 };
778
779 LeaveCriticalSection(&m_queueLock);
780}
781
782
783
784void SonyCommerce_Orbis::processMessage()
785{
786 EnterCriticalSection(&m_queueLock);
787 int ret;
788 if(m_messageQueue.empty())
789 {
790 LeaveCriticalSection(&m_queueLock);
791 return;
792 }
793 Message msg = m_messageQueue.front();
794 m_messageQueue.pop();
795
796 switch (msg)
797 {
798
799 case e_message_commerceCreateSession:
800 ret = createSession();
801 if (ret < 0)
802 {
803 m_event = e_event_commerceError;
804 m_errorCode = ret;
805 }
806 break;
807
808 case e_message_commerceGetCategoryInfo:
809 {
810 ret = getCategoryInfo(m_pCategoryInfo, m_pCategoryID);
811 if (ret < 0)
812 {
813 m_event = e_event_commerceError;
814 app.DebugPrintf(4,"ERROR - e_event_commerceGotCategoryInfo - %s\n",m_pCategoryID);
815 m_errorCode = ret;
816 }
817 break;
818 }
819
820 case e_message_commerceGetProductList:
821 {
822 ret = getProductList(m_pProductInfoList, m_pCategoryID);
823 if (ret < 0)
824 {
825 m_event = e_event_commerceError;
826 }
827 break;
828 }
829
830 case e_message_commerceGetDetailedProductInfo:
831 {
832 ret = getDetailedProductInfo(m_pProductInfoDetailed, m_pProductID, m_pCategoryID);
833 if (ret < 0)
834 {
835 m_event = e_event_commerceError;
836 m_errorCode = ret;
837 }
838 break;
839 }
840 case e_message_commerceAddDetailedProductInfo:
841 {
842 ret = addDetailedProductInfo(m_pProductInfo, m_pProductID, m_pCategoryID);
843 if (ret < 0)
844 {
845 m_event = e_event_commerceError;
846 m_errorCode = ret;
847 }
848 break;
849 }
850
851//
852// case e_message_commerceStoreProductBrowse:
853// {
854// ret = productBrowse(*(ProductBrowseParams *)msg.inputArgs);
855// if (ret < 0) {
856// m_event = e_event_commerceError;
857// m_errorCode = ret;
858// }
859// _TOOLKIT_NP_DEL (ProductBrowseParams *)msg.inputArgs;
860// break;
861// }
862//
863// case e_message_commerceUpgradeTrial:
864// {
865// ret = upgradeTrial();
866// if (ret < 0) {
867// m_event = e_event_commerceError;
868// m_errorCode = ret;
869// }
870// break;
871// }
872//
873// case e_message_commerceRedeemVoucher:
874// {
875// ret = voucherCodeInput(*(VoucherInputParams *)msg.inputArgs);
876// if (ret < 0) {
877// m_event = e_event_commerceError;
878// m_errorCode = ret;
879// }
880// _TOOLKIT_NP_DEL (VoucherInputParams *)msg.inputArgs;
881// break;
882// }
883//
884// case e_message_commerceGetEntitlementList:
885// {
886// Job<std::vector<SceNpEntitlement> > tmpJob(static_cast<Future<std::vector<SceNpEntitlement> > *>(msg.output));
887//
888// int state = 0;
889// int ret = sceNpManagerGetStatus(&state);
890//
891// // We don't want to process this if we are offline
892// if (ret < 0 || state != SCE_NP_MANAGER_STATUS_ONLINE) {
893// m_event = e_event_commerceError;
894// reply.returnCode = SCE_TOOLKIT_NP_OFFLINE;
895// tmpJob.setError(SCE_TOOLKIT_NP_OFFLINE);
896// } else {
897// getEntitlementList(&tmpJob);
898// }
899// break;
900// }
901//
902// case e_message_commerceConsumeEntitlement:
903// {
904// int state = 0;
905// int ret = sceNpManagerGetStatus(&state);
906//
907// // We don't want to process this if we are offline
908// if (ret < 0 || state != SCE_NP_MANAGER_STATUS_ONLINE) {
909// m_event = e_event_commerceError;
910// reply.returnCode = SCE_TOOLKIT_NP_OFFLINE;
911// } else {
912//
913// ret = consumeEntitlement(*(EntitlementToConsume *)msg.inputArgs);
914// if (ret < 0) {
915// m_event = e_event_commerceError;
916// m_errorCode = ret;
917// } else {
918// m_event = e_event_commerceConsumedEntitlement;
919// }
920// }
921// _TOOLKIT_NP_DEL (EntitlementToConsume *)msg.inputArgs;
922//
923// break;
924// }
925//
926 case e_message_commerceCheckout:
927 {
928 ret = checkout(m_checkoutInputParams);
929 if (ret < 0) {
930 m_event = e_event_commerceError;
931 m_errorCode = ret;
932 }
933 break;
934 }
935
936 case e_message_commerceDownloadList:
937 {
938 ret = downloadList(m_downloadInputParams);
939 if (ret < 0) {
940 m_event = e_event_commerceError;
941 m_errorCode = ret;
942 }
943 break;
944 }
945
946 case e_message_commerceCheckout_Game:
947 {
948 ret = checkout_game(m_checkoutInputParams);
949 if (ret < 0) {
950 m_event = e_event_commerceError;
951 m_errorCode = ret;
952 }
953 break;
954 }
955
956 case e_message_commerceDownloadList_Game:
957 {
958 ret = downloadList_game(m_downloadInputParams);
959 if (ret < 0) {
960 m_event = e_event_commerceError;
961 m_errorCode = ret;
962 }
963 break;
964 }
965
966 case e_message_commerceEnd:
967 app.DebugPrintf("XXX - e_message_commerceEnd!\n");
968 ret = commerceEnd();
969 if (ret < 0)
970 {
971 m_event = e_event_commerceError;
972 m_errorCode = ret;
973 }
974 // 4J-PB - we don't seem to handle the error code here
975 else if(m_errorCode!=0)
976 {
977 m_event = e_event_commerceError;
978 }
979 break;
980
981 default:
982 break;
983 }
984
985 LeaveCriticalSection(&m_queueLock);
986}
987
988
989void SonyCommerce_Orbis::processEvent()
990{
991 int ret = 0;
992
993 switch (m_event)
994 {
995 case e_event_none:
996 break;
997 case e_event_commerceSessionCreated:
998 app.DebugPrintf(4,"Commerce Session Created.\n");
999 runCallback();
1000 break;
1001 case e_event_commerceSessionAborted:
1002 app.DebugPrintf(4,"Commerce Session aborted.\n");
1003 runCallback();
1004 break;
1005 case e_event_commerceGotProductList:
1006 app.DebugPrintf(4,"Got product list.\n");
1007 runCallback();
1008 break;
1009 case e_event_commerceGotCategoryInfo:
1010 app.DebugPrintf(4,"Got category info\n");
1011 runCallback();
1012 break;
1013 case e_event_commerceGotDetailedProductInfo:
1014 app.DebugPrintf(4,"Got detailed product info.\n");
1015 runCallback();
1016 break;
1017 case e_event_commerceAddedDetailedProductInfo:
1018 app.DebugPrintf(4,"Added detailed product info.\n");
1019 runCallback();
1020 break;
1021 case e_event_commerceProductBrowseStarted:
1022 break;
1023 case e_event_commerceProductBrowseSuccess:
1024 break;
1025 case e_event_commerceProductBrowseAborted:
1026 break;
1027 case e_event_commerceProductBrowseFinished:
1028 app.DebugPrintf(4,"e_event_commerceProductBrowseFinished succeeded: 0x%x\n", m_errorCode);
1029
1030 if(m_callbackFunc!=NULL)
1031 {
1032 runCallback();
1033 }
1034
1035 //assert(0);
1036// ret = sys_memory_container_destroy(s_memContainer);
1037// if (ret < 0) {
1038// printf("Failed to destroy memory container");
1039// }
1040// s_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID;
1041 break;
1042 case e_event_commerceVoucherInputStarted:
1043 break;
1044 case e_event_commerceVoucherInputSuccess:
1045 break;
1046 case e_event_commerceVoucherInputAborted:
1047 break;
1048 case e_event_commerceVoucherInputFinished:
1049 assert(0);
1050// ret = sys_memory_container_destroy(s_memContainer);
1051// if (ret < 0) {
1052// printf("Failed to destroy memory container");
1053// }
1054// s_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID;
1055 break;
1056 case e_event_commerceGotEntitlementList:
1057 break;
1058 case e_event_commerceConsumedEntitlement:
1059 break;
1060 case e_event_commerceCheckoutStarted:
1061 app.DebugPrintf(4,"Checkout Started\n");
1062 break;
1063 case e_event_commerceCheckoutSuccess:
1064 app.DebugPrintf(4,"Checkout succeeded: 0x%x\n", m_errorCode);
1065 // clear the DLC installed and check again
1066 app.ClearDLCInstalled();
1067 ui.HandleDLCInstalled(0);
1068 break;
1069 case e_event_commerceCheckoutAborted:
1070 app.DebugPrintf(4,"Checkout aborted: 0x%x\n", m_errorCode);
1071 break;
1072 case e_event_commerceCheckoutFinished:
1073 app.DebugPrintf(4,"Checkout Finished: 0x%x\n", m_errorCode);
1074 if (ret < 0) {
1075 app.DebugPrintf(4,"Failed to destroy memory container");
1076 }
1077
1078 // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time
1079 if(m_callbackFunc!=NULL)
1080 {
1081 runCallback();
1082 }
1083 break;
1084 case e_event_commerceDownloadListStarted:
1085 app.DebugPrintf(4,"Download List Started\n");
1086 break;
1087 case e_event_commerceDownloadListSuccess:
1088 app.DebugPrintf(4,"Download succeeded: 0x%x\n", m_errorCode);
1089 break;
1090 case e_event_commerceDownloadListFinished:
1091 app.DebugPrintf(4,"Download Finished: 0x%x\n", m_errorCode);
1092 if (ret < 0) {
1093 app.DebugPrintf(4,"Failed to destroy memory container");
1094 }
1095
1096 // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time
1097 if(m_callbackFunc!=NULL)
1098 {
1099 runCallback();
1100 }
1101 break;
1102 case e_event_commerceError:
1103 app.DebugPrintf(4,"Commerce Error 0x%x\n", m_errorCode);
1104 runCallback();
1105 break;
1106 default:
1107 break;
1108 }
1109 m_event = e_event_none;
1110}
1111
1112
1113int SonyCommerce_Orbis::commerceEnd()
1114{
1115 int ret = 0;
1116
1117// if (m_currentPhase == e_phase_voucherRedeemPhase)
1118// ret = sceNpCommerce2DoProductCodeFinishAsync(m_contextId);
1119// else if (m_currentPhase == e_phase_productBrowsePhase)
1120// ret = sceNpCommerce2DoProductBrowseFinishAsync(m_contextId);
1121// else if (m_currentPhase == e_phase_creatingSessionPhase)
1122// ret = sceNpCommerce2CreateSessionFinish(m_contextId, &m_sessionInfo);
1123// else if (m_currentPhase == e_phase_checkoutPhase)
1124// ret = sceNpCommerce2DoCheckoutFinishAsync(m_contextId);
1125// else if (m_currentPhase == e_phase_downloadListPhase)
1126// ret = sceNpCommerce2DoDlListFinishAsync(m_contextId);
1127
1128 m_currentPhase = e_phase_idle;
1129
1130 return ret;
1131}
1132
1133void SonyCommerce_Orbis::CreateSession( CallbackFunc cb, LPVOID lpParam )
1134{
1135 // 4J-PB - reset any previous error code
1136 // I had this happen when I was offline on Vita, and accepted the PSN sign-in
1137 // the m_errorCode was picked up in the message queue after the commerce init call
1138 if(m_errorCode!=0)
1139 {
1140 app.DebugPrintf("m_errorCode was set!\n");
1141 m_errorCode=0;
1142 }
1143 Init();
1144 EnterCriticalSection(&m_queueLock);
1145 setCallback(cb,lpParam);
1146
1147 // We don't need to create a session on PS4, from the Sony docs -
1148// This function is provided to maintain compatibility with the PlayStation�Vita and PlayStation�3
1149// platforms. Because commerce on the PlayStation�4 is not session based, SCE_TOOLKIT_NP_SUCCESS is always returned.
1150
1151
1152
1153// m_messageQueue.push(e_message_commerceCreateSession);
1154 m_messageQueue.push(e_message_commerceEnd);
1155 m_event = e_event_commerceSessionCreated;
1156
1157 if(m_tickThread == NULL)
1158 m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_Orbis tick");
1159 if(m_tickThread->isRunning() == false)
1160 {
1161 m_currentPhase = e_phase_idle;
1162 m_tickThread->Run();
1163 }
1164 LeaveCriticalSection(&m_queueLock);
1165}
1166
1167void SonyCommerce_Orbis::CloseSession()
1168{
1169 assert(m_currentPhase == e_phase_idle);
1170 m_currentPhase = e_phase_stopped;
1171 // 4J-PB - don't call shutdown here - the SonyCommerce_Orbis::TickLoop thread is still running and could crash accessing the critical section that Shutdown destroys
1172 //Shutdown();
1173}
1174
1175void SonyCommerce_Orbis::GetProductList( CallbackFunc cb, LPVOID lpParam, std::vector<ProductInfo>* productList, const char *categoryId)
1176{
1177 EnterCriticalSection(&m_queueLock);
1178 setCallback(cb,lpParam);
1179 m_pProductInfoList = productList;
1180 strcpy(m_pCategoryID,categoryId);
1181 m_messageQueue.push(e_message_commerceGetProductList);
1182 LeaveCriticalSection(&m_queueLock);
1183}
1184
1185void SonyCommerce_Orbis::GetDetailedProductInfo( CallbackFunc cb, LPVOID lpParam, ProductInfoDetailed* productInfo, const char *productId, const char *categoryId )
1186{
1187 EnterCriticalSection(&m_queueLock);
1188 setCallback(cb,lpParam);
1189 m_pProductInfoDetailed = productInfo;
1190 m_pProductID = productId;
1191 strcpy(m_pCategoryID,categoryId);
1192 m_messageQueue.push(e_message_commerceGetDetailedProductInfo);
1193 LeaveCriticalSection(&m_queueLock);
1194}
1195
1196// 4J-PB - fill out the long description and the price for the product
1197void SonyCommerce_Orbis::AddDetailedProductInfo( CallbackFunc cb, LPVOID lpParam, ProductInfo* productInfo, const char *productId, const char *categoryId )
1198{
1199 EnterCriticalSection(&m_queueLock);
1200 setCallback(cb,lpParam);
1201 m_pProductInfo = productInfo;
1202 m_pProductID = productId;
1203 strcpy(m_pCategoryID,categoryId);
1204 m_messageQueue.push(e_message_commerceAddDetailedProductInfo);
1205 LeaveCriticalSection(&m_queueLock);
1206}
1207void SonyCommerce_Orbis::GetCategoryInfo( CallbackFunc cb, LPVOID lpParam, CategoryInfo *info, const char *categoryId )
1208{
1209 EnterCriticalSection(&m_queueLock);
1210 setCallback(cb,lpParam);
1211 m_pCategoryInfo = info;
1212 strcpy(m_pCategoryID,categoryId);
1213 m_messageQueue.push(e_message_commerceGetCategoryInfo);
1214 LeaveCriticalSection(&m_queueLock);
1215}
1216
1217void SonyCommerce_Orbis::Checkout( CallbackFunc cb, LPVOID lpParam, const char* skuID )
1218{
1219 EnterCriticalSection(&m_queueLock);
1220 setCallback(cb,lpParam);
1221 m_checkoutInputParams.skuIds.clear();
1222 m_checkoutInputParams.skuIds.push_back(skuID);
1223 m_messageQueue.push(e_message_commerceCheckout);
1224 LeaveCriticalSection(&m_queueLock);
1225}
1226
1227void SonyCommerce_Orbis::DownloadAlreadyPurchased( CallbackFunc cb, LPVOID lpParam, const char* skuID )
1228{
1229 EnterCriticalSection(&m_queueLock);
1230 setCallback(cb,lpParam);
1231 m_downloadInputParams.skuIds.clear();
1232 m_downloadInputParams.skuIds.push_back(skuID);
1233 m_messageQueue.push(e_message_commerceDownloadList);
1234 LeaveCriticalSection(&m_queueLock);
1235}
1236
1237void SonyCommerce_Orbis::Checkout_Game( CallbackFunc cb, LPVOID lpParam, const char* skuID )
1238{
1239 EnterCriticalSection(&m_queueLock);
1240 setCallback(cb,lpParam);
1241 m_checkoutInputParams.skuIds.clear();
1242 m_checkoutInputParams.skuIds.push_back(skuID);
1243 m_messageQueue.push(e_message_commerceCheckout_Game);
1244 LeaveCriticalSection(&m_queueLock);
1245}
1246void SonyCommerce_Orbis::DownloadAlreadyPurchased_Game( CallbackFunc cb, LPVOID lpParam, const char* skuID )
1247{
1248 EnterCriticalSection(&m_queueLock);
1249 setCallback(cb,lpParam);
1250 m_downloadInputParams.skuIds.clear();
1251 m_downloadInputParams.skuIds.push_back(skuID);
1252 m_messageQueue.push(e_message_commerceDownloadList_Game);
1253 LeaveCriticalSection(&m_queueLock);
1254}
1255
1256
1257/*
1258bool g_bDoCommerceCreateSession = false;
1259bool g_bDoCommerceGetProductList = false;
1260bool g_bDoCommerceGetCategoryInfo = false;
1261bool g_bDoCommerceGetProductInfoDetailed = false;
1262bool g_bDoCommerceCheckout = false;
1263bool g_bDoCommerceCloseSession = false;
1264const char* g_category = "EP4433-CUSA00265_00";
1265const char* g_skuID = "SKINPACK00000001-E001";
1266std::vector<SonyCommerce::ProductInfo> g_productInfo;
1267SonyCommerce::CategoryInfo g_categoryInfo2;
1268SonyCommerce::ProductInfoDetailed g_productInfoDetailed;
1269
1270void testCallback(LPVOID lpParam, int error_code)
1271{
1272 app.DebugPrintf("Callback hit, error 0x%08x\n", error_code);
1273}
1274
1275void SonyCommerce_Orbis::Test()
1276{
1277 int err = SCE_OK;
1278 if(g_bDoCommerceCreateSession)
1279 {
1280 CreateSession(testCallback, this);
1281 g_bDoCommerceCreateSession = false;
1282 }
1283 if(g_bDoCommerceGetProductList)
1284 {
1285 GetProductList(testCallback, this, &g_productInfo, g_category);
1286 g_bDoCommerceGetProductList = false;
1287 }
1288
1289 if(g_bDoCommerceGetCategoryInfo)
1290 {
1291 GetCategoryInfo(testCallback, this, &g_categoryInfo2, g_category);
1292 g_bDoCommerceGetCategoryInfo = false;
1293 }
1294
1295 if(g_bDoCommerceGetProductInfoDetailed)
1296 {
1297 GetDetailedProductInfo(testCallback, this, &g_productInfoDetailed, g_productInfo[0].productId, g_category);
1298 g_bDoCommerceGetProductInfoDetailed = false;
1299 }
1300
1301 if(g_bDoCommerceCheckout)
1302 {
1303 //Checkout(testCallback, this, g_skuID);//g_productInfoDetailed.skuId);
1304 Checkout(testCallback, this, g_productInfoDetailed.skuId);
1305 g_bDoCommerceCheckout = false;
1306 }
1307 if(g_bDoCommerceCloseSession)
1308 {
1309 CloseSession();
1310 g_bDoCommerceCloseSession = false;
1311 }
1312
1313}
1314*/