summaryrefslogtreecommitdiff
path: root/src/modules/mega/mega.h
blob: e7f4f8026c281a4c638b9c268cbda2ac5273ad46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <skypunch_private.h>
#include <aes.h>
#include <cencode.h>
#include <cJSON.h>

typedef enum _Mega_Action_Type
{
   MEGA_LOGIN
} Mega_Action_Type;

typedef struct _Mega
{
   Skypunch *skypunch;
   Ecore_Con_Url *ecu;
   void *action;

   struct
   {
      const char *email,
                 *password;
   } info;

   struct
   {
      char password[16],
           *id,
           *private_key,
           *master_key;
   } session;

   struct
   {
      Ecore_Event_Handler *ed,
                          *ec;
   } ev;
} Mega;

typedef struct _Mega_Action_Login
{
   Eina_Strbuf *buf;
} Mega_Action_Login;

typedef struct _Mega_Action
{
   Mega_Action_Type type;

   Mega *mega;
   void *data;

   union
   {
      Mega_Action_Login al;
   } u;

   struct
   {
      
   } cb;
} Mega_Action;

Eina_Bool mega_event_data(void *data, int type, void *event_info);
Eina_Bool mega_event_complete(void *data, int type, void *event_info);


Eina_Bool mega_login_send(Mega *mega, const char *json);
const char * mega_login_json(const char *email, const char *hash);
const char * mega_login_encode(Mega *mega, const char *auth);

void mega_utils_print(const char *s, int len);
char * mega_utils_base64_encode(const unsigned char *string, size_t len, size_t *size);
const char * mega_utils_key_encode(const char *s);
const char * mega_utils_login_hash(const char *email, const char *password);