summaryrefslogtreecommitdiff
path: root/plugin/plugin.h
blob: 3fbfe51b527e474e127c31cf1434f4dc08bf7d5e (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*

  Copyright (c) 2009 Samuel Lidén Borell <samuel@slbdata.se>
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.

*/

#ifndef __PLUGIN_H__
#define __PLUGIN_H__

typedef enum {
    PT_Version,
    PT_Authentication,
    PT_Signer,
} PluginType;

typedef enum {
    PE_OK = 0,
    PE_UnknownError = 1, // Maybe this is used for something else in the original plugin?
} PluginError;

typedef struct {
    PluginType type;
    
    char *url;
    char *hostname;
    char *ip;
    int windowId;
    PluginError lastError;
    
    union {
        struct {
            /* Input parameters */
            char *challenge;
            char *policys;
            void *dummy1; // To be compatible with .sign below
            void *dummy0;
            /* Output parameters */
            char *signature;
        } auth;
        struct {
            /* Input parameters */
            char *challenge;
            char *policys;
            char *subjectFilter;
            char *message;
            /* Output parameters */
            char *signature;
        } sign;
    } info;
} Plugin;

/* Plugin creation */
Plugin *plugin_new(PluginType pluginType, const char *url,
                   const char *hostname, const char *ip,
                   int windowId);
void plugin_free(Plugin *plugin);

/* Javascript API */
char *version_getVersion(Plugin *plugin);

char *sign_getParam(Plugin *plugin, const char *name);
bool sign_setParam(Plugin *plugin, const char *name, const char *value);
int sign_performAction(Plugin *plugin, const char *action);
int sign_performAction_Authenticate(Plugin *plugin);
int sign_performAction_Sign(Plugin *plugin);
int sign_getLastError(Plugin *plugin);
// TODO more functions...

#endif