~cahr-gr/gloobus-preview/monitors

« back to all changes in this revision

Viewing changes to src/plugin-compressed/plugin-compressed.h

  • Committer: Jordi Puigdellívol
  • Date: 2010-05-26 14:35:12 UTC
  • mfrom: (213.1.33 gloobus-preview)
  • Revision ID: jordi@badchoice-20100526143512-bhndzc2y7o8un30v
Merged, now its really good

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef _ICOMPRESSED_
2
2
#define _ICOMPRESSED_
3
3
 
4
 
#define MANAGER_VERSION 1                               // TODO: Define here the pluginManager version !!! (In pluginManager.h)
5
 
#define PLUGIN_NAME             "compressed"    // TODO: Define here the plugin Name
6
 
 
7
 
#include "../gloobus-preview-interface-list.h"
8
 
 
9
 
#include <cstdlib>
10
 
#include <csignal>
11
 
//#include <stdlib.h>
12
 
#include <string>
13
 
 
14
 
/*Translations*/
15
 
#include <libintl.h>
16
 
#include <locale.h>
17
 
#define _(String) gettext(String)
18
 
 
19
 
 
20
 
#include <sys/types.h>
21
 
#include <dirent.h>
22
 
#include <errno.h>
23
 
#include <vector>
24
 
#include <string>
25
 
#include <iostream>
26
 
#include <algorithm>
27
 
 
28
 
#include <gio/gio.h>
29
 
 
30
4
#define GP_COMPRESSED_7Z       "application/x-7z-compressed"
31
5
#define GP_COMPRESSED_RAR      "application/rar"
32
6
#define GP_COMPRESSED_RAR_X    "application/x-rar"
41
15
#define GP_COMPRESSED_TAR_Z    "application/x-tarz"
42
16
#define GP_COMPRESSED_ZIP      "application/zip"
43
17
 
 
18
#ifndef PLUGIN_LOADER
 
19
 
 
20
//#include <cstdlib>
 
21
//#include <csignal>
 
22
//#include <stdlib.h>
 
23
//#include <string>
 
24
 
 
25
/*Translations*/
 
26
//#include <libintl.h>
 
27
//#include <locale.h>
 
28
//#define _(String) gettext(String)
 
29
 
 
30
 
 
31
//#include <sys/types.h>
 
32
//#include <dirent.h>
 
33
//#include <errno.h>
 
34
#include <string>
 
35
#include <vector>
 
36
//#include <iostream>
 
37
//#include <algorithm>
 
38
 
 
39
//#include <gio/gio.h>
 
40
 
 
41
//#include "../gloobus-preview-plugin-manager.h"
 
42
#include "../gloobus-preview-interface-list.h"
 
43
 
44
44
class iCompressed : public iList
45
45
{
46
46
        private:
80
80
};
81
81
 
82
82
 
83
 
 
84
 
// ============================ Class factories======================================== //
85
 
// This is "allways the same" code, just change the plugin name in the printf and the 
86
 
// return object
87
 
extern "C" iList* create() {            
 
83
extern "C" interface * create() {               
88
84
    return new iCompressed;
89
85
}
90
86
 
91
 
extern "C" void destroy(iList* p) {
92
 
    delete p;
 
87
extern "C" void destroy(interface * p) {
 
88
    delete (iCompressed*)p;
93
89
}
94
90
 
95
 
extern "C" int getVersion(){                    //To save crashes from older versions
 
91
extern "C" int getVersion() {
96
92
        return MANAGER_VERSION;
97
93
}
98
94
 
99
 
// ============================== REGISTER ============================================ //
100
 
// Here is where we register the new plugin, what we do is to add a map with the plugin
101
 
// name and the mime file types it can load, then, the pluginManager will take care of wich
102
 
// plugin load, depending on its file type. Just add more than one file type adding this
103
 
// two lines as many times you want.
104
 
//
105
 
//      itself.filetype = "image/bmp";                  // Add another extension supported
106
 
//      pluginVector.push_back(itself);                 // Add filetype that plugin reads
107
 
 
108
 
extern "C" 
109
 
{
110
 
        class proxy {
111
 
                public:
112
 
                proxy() {
113
 
                        factory_list[PLUGIN_NAME] = create;
114
 
                        factoryDestroy_list[PLUGIN_NAME] = destroy;
115
 
 
116
 
                        plugin_filetype itself = {
117
 
                                PLUGIN_NAME,
118
 
                                GP_COMPRESSED_7Z,
119
 
                                "list",
120
 
                                1
121
 
                        };
122
 
                        if(interface::is_program_available("7z"))
123
 
                                pluginVector.push_back(itself);
124
 
 
125
 
                        if(interface::is_program_available("unrar")) {
126
 
                                itself.filetype = GP_COMPRESSED_RAR;
127
 
                                pluginVector.push_back(itself);
128
 
 
129
 
                                itself.filetype = GP_COMPRESSED_RAR_X;
130
 
                                pluginVector.push_back(itself);
131
 
                        }
132
 
 
133
 
                        if(interface::is_program_available("tar")) {
134
 
                                itself.filetype = GP_COMPRESSED_TAR;
135
 
                                pluginVector.push_back(itself);
136
 
 
137
 
                                itself.filetype = GP_COMPRESSED_TAR_7Z;
138
 
                                pluginVector.push_back(itself);
139
 
 
140
 
                                itself.filetype = GP_COMPRESSED_TAR_BZIP;
141
 
                                pluginVector.push_back(itself);
142
 
 
143
 
                                itself.filetype = GP_COMPRESSED_TAR_LZIP;
144
 
                                pluginVector.push_back(itself);
145
 
 
146
 
                                itself.filetype = GP_COMPRESSED_TAR_LZMA;
147
 
                                pluginVector.push_back(itself);
148
 
 
149
 
                                itself.filetype = GP_COMPRESSED_TAR_LZOP;
150
 
                                pluginVector.push_back(itself);
151
 
 
152
 
                                itself.filetype = GP_COMPRESSED_TAR_X;
153
 
                                pluginVector.push_back(itself);
154
 
 
155
 
                                itself.filetype = GP_COMPRESSED_TAR_XZ;
156
 
                                pluginVector.push_back(itself);
157
 
 
158
 
                                itself.filetype = GP_COMPRESSED_TAR_Z;
159
 
                                pluginVector.push_back(itself);
160
 
                        }
161
 
 
162
 
                        if(interface::is_program_available("zipinfo")) {
163
 
                                itself.filetype = GP_COMPRESSED_ZIP;
164
 
                                pluginVector.push_back(itself);
165
 
                        }
166
 
                }
167
 
        };
168
 
        proxy p;        // When we open the dll with RTLD_NOW it creates p, and in consequence, it registers the plugin 
169
 
}
170
 
 
171
 
#endif
172
 
 
 
95
#endif
 
96
 
 
97
#ifdef PLUGIN_LOADER
 
98
 
 
99
PluginManager::register_plugin("compressed");
 
100
 
 
101
if(interface::is_program_available("7z")) {
 
102
        PluginManager::register_filetype(GP_COMPRESSED_7Z, 1);
 
103
}
 
104
 
 
105
if(interface::is_program_available("unrar")) {
 
106
        PluginManager::register_filetype(GP_COMPRESSED_RAR, 1);
 
107
        PluginManager::register_filetype(GP_COMPRESSED_RAR_X, 1);
 
108
}
 
109
 
 
110
if(interface::is_program_available("tar")) {
 
111
        PluginManager::register_filetype(GP_COMPRESSED_TAR, 1);
 
112
        PluginManager::register_filetype(GP_COMPRESSED_TAR_7Z, 1);
 
113
        PluginManager::register_filetype(GP_COMPRESSED_TAR_BZIP, 1);
 
114
        PluginManager::register_filetype(GP_COMPRESSED_TAR_LZIP, 1);
 
115
        PluginManager::register_filetype(GP_COMPRESSED_TAR_LZMA, 1);
 
116
        PluginManager::register_filetype(GP_COMPRESSED_TAR_LZOP, 1);
 
117
        PluginManager::register_filetype(GP_COMPRESSED_TAR_X, 1);
 
118
        PluginManager::register_filetype(GP_COMPRESSED_TAR_XZ, 1);
 
119
        PluginManager::register_filetype(GP_COMPRESSED_TAR_Z, 1);
 
120
}
 
121
 
 
122
if(interface::is_program_available("zipinfo")) {
 
123
        PluginManager::register_filetype(GP_COMPRESSED_ZIP, 1);
 
124
}
 
125
 
 
126
#endif
 
127
 
 
128
#endif