~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/errmsg_notify/errmsg_notify.cc

  • Committer: Brian Aker
  • Date: 2010-02-03 21:54:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1281.
  • Revision ID: brian@gaz-20100203215438-9ixkp214vio85mub
Fixing test cases/removed dead optimizer switches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <cstdio>  /* for vsnprintf */
23
23
#include <stdarg.h>  /* for va_list */
24
24
#include <unistd.h>  /* for write(2) */
25
 
#include <iostream>
26
25
#include <libnotifymm.h>
27
 
#include <boost/scoped_ptr.hpp>
28
26
 
29
27
#include <string>
30
28
#include <vector>
32
30
#include <drizzled/plugin/error_message.h>
33
31
#include <drizzled/gettext.h>
34
32
#include <drizzled/plugin.h>
 
33
#include <drizzled/plugin/registry.h>
35
34
 
36
35
 
37
36
/* todo, make this dynamic as needed */
38
37
#define MAX_MSG_LEN 8192
39
38
 
40
39
using namespace drizzled;
 
40
using namespace std;
 
41
 
41
42
 
42
43
class Error_message_notify : public plugin::ErrorMessage
43
44
{
44
 
  std::vector<std::string> errmsg_tags;
 
45
  vector<string> errmsg_tags;
45
46
public:
46
47
  Error_message_notify()
47
48
   : plugin::ErrorMessage("Error_message_notify"),
73
74
    {
74
75
      if (!n.show())
75
76
#else
76
 
      boost::scoped_ptr<Glib::Error> error;
 
77
      auto_ptr<Glib::Error> error;
77
78
      if (!n.show(error))
78
79
#endif
79
80
      {
80
 
        std::cerr << _("Failed to send error message to libnotify\n");
 
81
        fprintf(stderr, _("Failed to send error message to libnotify\n"));
81
82
        return true;
82
83
      }
83
84
#ifdef GLIBMM_EXCEPTIONS_ENABLED
84
85
     }
85
86
     catch (Glib::Error& err)
86
87
     {
87
 
       std::cerr << err.what() << std::endl;
 
88
        fprintf(stderr, err.what().c_str());
88
89
     }
89
90
#endif
90
91
 
94
95
};
95
96
 
96
97
static Error_message_notify *handler= NULL;
97
 
static int plugin_init(module::Context &context)
 
98
static int plugin_init(plugin::Registry &registry)
98
99
{
99
100
  Notify::init("Drizzled");
100
101
  handler= new Error_message_notify();
101
 
  context.add(handler);
102
 
 
103
 
  return 0;
104
 
}
105
 
 
106
 
DRIZZLE_PLUGIN(plugin_init, NULL, NULL);
 
102
  registry.add(handler);
 
103
 
 
104
  return 0;
 
105
}
 
106
 
 
107
static int plugin_deinit(plugin::Registry &registry)
 
108
{
 
109
 
 
110
  if (handler)
 
111
  {
 
112
    registry.remove(handler);
 
113
    delete handler;
 
114
  }
 
115
  return 0;
 
116
}
 
117
 
 
118
DRIZZLE_PLUGIN(plugin_init, plugin_deinit, NULL, NULL);