2012-07-27 19:26:49 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
2012-05-12 18:03:14 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "gcard.h"
|
|
|
|
#include "http.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "loader/utils.h"
|
2012-12-08 17:17:35 +01:00
|
|
|
#include "gecko/gecko.hpp"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#define MAX_URL_SIZE 178 // 128 + 48 + 6
|
|
|
|
|
|
|
|
struct provider
|
|
|
|
{
|
|
|
|
char url[128];
|
|
|
|
char key[48];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct provider *providers = NULL;
|
|
|
|
int amount_of_providers = 0;
|
|
|
|
|
|
|
|
u8 register_card_provider(const char *url, const char *key)
|
|
|
|
{
|
2012-02-24 22:08:24 +01:00
|
|
|
if (strlen(url) > 0 && strlen(key) > 0 && strstr(url, "{KEY}") != NULL && strstr(url, "{ID6}") != NULL)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-02-24 22:08:24 +01:00
|
|
|
providers = (struct provider *) realloc(providers, (amount_of_providers + 1) * sizeof(struct provider));
|
2012-01-21 21:57:41 +01:00
|
|
|
memset(&providers[amount_of_providers], 0, sizeof(struct provider));
|
|
|
|
strncpy((char *) providers[amount_of_providers].url, url, 128);
|
|
|
|
strncpy((char *) providers[amount_of_providers].key, key, 48);
|
|
|
|
amount_of_providers++;
|
2012-02-18 14:51:55 +01:00
|
|
|
gprintf("Gamercard provider is valid!\n");
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2012-02-18 14:51:55 +01:00
|
|
|
gprintf("Gamertag provider is NOT valid!\n");
|
2012-01-21 21:57:41 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 has_enabled_providers()
|
|
|
|
{
|
2012-02-24 22:08:24 +01:00
|
|
|
if (amount_of_providers != 0 && providers != NULL)
|
|
|
|
return 1;
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void add_game_to_card(const char *gameid)
|
|
|
|
{
|
|
|
|
int i;
|
2012-02-23 20:08:34 +01:00
|
|
|
|
2012-07-27 19:26:49 +02:00
|
|
|
char *url = (char *)malloc(MAX_URL_SIZE); // Too much memory, but only like 10 bytes
|
2012-01-21 21:57:41 +01:00
|
|
|
memset(url, 0, sizeof(url));
|
2012-02-23 20:08:34 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
for (i = 0; i < amount_of_providers && providers != NULL; i++)
|
|
|
|
{
|
2012-02-24 22:08:24 +01:00
|
|
|
strcpy(url, (char *) providers[i].url);
|
|
|
|
str_replace(url, (char *) "{KEY}", (char *) providers[i].key, MAX_URL_SIZE);
|
|
|
|
str_replace(url, (char *) "{ID6}", (char *) gameid, MAX_URL_SIZE);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-02-24 22:08:24 +01:00
|
|
|
gprintf("Gamertag URL:\n%s\n",(char*)url);
|
|
|
|
downloadfile(NULL, 0, (char *) url, NULL, NULL);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-07-27 19:26:49 +02:00
|
|
|
free(url);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|