~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to plugins/db.mysql/backend/wb_plugin_be.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "stdafx.h"
 
2
 
 
3
#include "wb_plugin_be.h"
 
4
 
 
5
 
 
6
void Wb_plugin::grtm(bec::GRTManager *grtm)
 
7
{
 
8
  _grtm= grtm;
 
9
  if (_grtm)
 
10
  {
 
11
    grt::GRT *grt= _grtm->get_grt();
 
12
    _options= grt::DictRef(grt);
 
13
  }
 
14
}
 
15
 
 
16
 
 
17
void Wb_plugin::exec_task(bool sync)
 
18
{
 
19
  set_task_proc();
 
20
 
 
21
  bec::GRTTask *task= new bec::GRTTask(task_desc(), _grtm->get_dispatcher(), _task_proc_cb);
 
22
 
 
23
  scoped_connect(task->signal_message(),boost::bind(&Wb_plugin::process_task_msg, this, _1));
 
24
  scoped_connect(task->signal_failed(),boost::bind(&Wb_plugin::process_task_fail, this, _1));
 
25
  scoped_connect(task->signal_finished(),boost::bind(&Wb_plugin::process_task_finish, this, _1));
 
26
 
 
27
  if (sync)
 
28
    _grtm->get_dispatcher()->add_task_and_wait(task);
 
29
  else
 
30
    _grtm->get_dispatcher()->add_task(task);
 
31
}
 
32
 
 
33
 
 
34
void Wb_plugin::process_task_msg(const grt::Message &msg)
 
35
{
 
36
  switch (msg.type)
 
37
  {
 
38
  case grt::WarningMsg:
 
39
  case grt::ErrorMsg:
 
40
  case grt::InfoMsg:
 
41
    if (_task_msg_cb)
 
42
      _task_msg_cb(msg.type, msg.text);
 
43
    break;
 
44
  case grt::ProgressMsg:
 
45
    if (_task_progress_cb)
 
46
      _task_progress_cb(msg.progress, msg.text);
 
47
    break;
 
48
  default:
 
49
    break;
 
50
  }
 
51
}
 
52
 
 
53
 
 
54
void Wb_plugin::process_task_fail(const std::exception &error)
 
55
{
 
56
  if (_task_fail_cb)
 
57
    _task_fail_cb(error.what());
 
58
}
 
59
 
 
60
 
 
61
void Wb_plugin::process_task_finish(grt::ValueRef res)
 
62
{
 
63
  _grtm->get_grt()->send_info(grt::StringRef::cast_from(res));
 
64
  //_grtm->get_grt()->make_output_visible();
 
65
  _grtm->perform_idle_tasks();
 
66
  if (_task_fail_cb)
 
67
    _task_finish_cb();
 
68
}
 
69
 
 
70
 
 
71
template<typename T1, typename T2>
 
72
T2 get_option(const grt::DictRef &options, const std::string &name)
 
73
{
 
74
  T2 value;
 
75
  if (options.is_valid() && options.has_key(name))
 
76
    value= (T2)T1::cast_from(options.get(name));
 
77
  return value;
 
78
}
 
79
 
 
80
 
 
81
int Wb_plugin::get_int_option(const std::string &name)
 
82
{
 
83
  return get_option<grt::IntegerRef, int>(_options, name);
 
84
}
 
85
 
 
86
 
 
87
double Wb_plugin::get_double_option(const std::string &name)
 
88
{
 
89
  return get_option<grt::DoubleRef, double>(_options, name);
 
90
}
 
91
 
 
92
 
 
93
std::string Wb_plugin::get_string_option(const std::string &name)
 
94
{
 
95
  return get_option<grt::StringRef, std::string>(_options, name);
 
96
}
 
97
 
 
98
 
 
99
void Wb_plugin::set_option(const std::string &name, int val)
 
100
{
 
101
  _options.set(name, grt::IntegerRef(val));
 
102
}
 
103
 
 
104
 
 
105
void Wb_plugin::set_option(const std::string &name, const double &val)
 
106
{
 
107
  _options.set(name, grt::DoubleRef(val));
 
108
}
 
109
 
 
110
 
 
111
void Wb_plugin::set_option(const std::string &name, const std::string &val)
 
112
{
 
113
  _options.set(name, grt::StringRef(val));
 
114
}