~gloobus-dev/gloobus-preview/trunk

« back to all changes in this revision

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

  • Committer: Jordi Puigdellívol
  • Date: 2010-04-05 10:02:37 UTC
  • mfrom: (182.1.31 gloobus-preview)
  • Revision ID: jordi@badchoice-20100405100237-2hxi07cmxqwuvcxm
Merged with cahr

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef _ICOMIC_
2
2
#define _ICOMIC_
3
3
 
4
 
#define MANAGER_VERSION 1                       // TODO: Define here the pluginManager version !!! (In pluginManager.h)
5
 
#define PLUGIN_NAME             "iComic"                // TODO: Define here the plugin Name
6
 
 
7
 
#include <gio/gio.h>
8
 
#include <string.h>
9
 
 
10
 
#include <iostream>
 
4
#ifndef PLUGIN_LOADER
 
5
 
 
6
//#include <gio/gio.h>
 
7
//#include <string.h>
 
8
 
 
9
//#include <iostream>
11
10
#include <algorithm>
12
11
#include <vector>
 
12
#include <string>
13
13
 
 
14
//#include "../gloobus-preview-plugin-manager.h"
14
15
#include "../gloobus-preview-interface-document.h"
15
16
 
16
17
using namespace std;
45
46
};
46
47
 
47
48
 
48
 
// ============================ Class factories======================================== //
49
 
// This is "allways the same" code, just change the plugin name in the printf and the 
50
 
// return object
51
 
extern "C" iDocument* create() {
 
49
extern "C" interface * create() {
52
50
    return new iComic;
53
51
}
54
52
 
55
 
extern "C" void destroy(iDocument* p) {
56
 
    delete p;
 
53
extern "C" void destroy(interface * p) {
 
54
    delete (iComic*)p;
57
55
}
58
56
 
59
 
extern "C" int getVersion(){                    //To save crashes from older versions
 
57
extern "C" int getVersion() {
60
58
        return MANAGER_VERSION;
61
59
}
62
60
 
63
 
// ============================== REGISTER ============================================ //
64
 
// Here is where we register the new plugin, what we do is to add a map with the plugin
65
 
// name and the mime file types it can load, then, the pluginManager will take care of wich
66
 
// plugin load, depending on its file type. Just add more than one file type adding this
67
 
// two lines as many times you want.
68
 
//
69
 
//      itself.filetype = "image/bmp";                  // Add another extension supported
70
 
//      pluginVector.push_back(itself);                 // Add filetype that plugin reads
71
 
 
72
 
extern "C" 
73
 
{
74
 
   class proxy {
75
 
                public:
76
 
                proxy()
77
 
                {
78
 
                        //TODO: Add here the mime filetypes that plugin supports
79
 
                        //plugin_filetype itself = {PLUGIN_NAME,EXTENSION,TYPE,PRIORITY}
80
 
                        
81
 
                        plugin_filetype itself = { PLUGIN_NAME, "application/x-cbz","document",1};              // Initial filetype
82
 
 
83
 
                        factory_document[itself.name] = create;                 // Register the plugin
84
 
                        factoryDestroy_document[itself.name] = destroy;         // Function for destroy this plugin class
85
 
                        pluginVector.push_back(itself);                                 // Add filetype that plugin reads
86
 
                        
87
 
                        itself.filetype = "application/x-cbr";                  // Add another extension supported
88
 
                        pluginVector.push_back(itself);                 // Add filetype that plugin reads
89
 
                    
90
 
           }
91
 
 };
92
 
 proxy p;       // When we open the dll with RTLD_NOW it creates p, and in consequence, it registers the plugin 
93
 
}
 
61
#endif
 
62
 
 
63
#ifdef PLUGIN_LOADER
 
64
 
 
65
PluginManager::register_plugin("comic");
 
66
 
 
67
PluginManager::register_filetype("application/x-cbz", 1);
 
68
PluginManager::register_filetype("application/x-cbr", 1);
 
69
 
 
70
#endif
94
71
 
95
72
#endif
96
73