Example #1
0
/*
 * We abuse the OAT_* hooks (which are intended for access control frameworks
 * such as sepgsql) for getting notified on relation create, alter, and drop
 * actions.  This is more reliable than digging around in the utility command
 * parse trees, as these hooks are called from the internal functions which
 * actually update the system catalogs, regardless of how those functions were
 * invoked.
 */
static void
objectaccess_hook(ObjectAccessType access,
	Oid classId,
	Oid objectId,
	int subId,
	void *arg)
{
	switch (access)
	{
		case OAT_POST_CREATE:
			on_create(classId, objectId, subId, (ObjectAccessPostCreate *)arg);
			break;

		/*
		 * The OAT_POST_ALTER hook is called from the following functions:
		 *
		 *	 [func]						[class]				[obj]			[subobj]
		 *   renameatt_internal			RelationRelationId	pg_class.oid	attnum
		 *   RenameRelationInternal		RelationRelationId	pg_class.oid	0
		 */
		case OAT_POST_ALTER:
			on_alter(classId, objectId, subId, (ObjectAccessPostAlter *)arg);
			break;

		case OAT_DROP:
			on_drop(classId, objectId, subId, (ObjectAccessDrop *)arg);
			break;

		case OAT_NAMESPACE_SEARCH:
		case OAT_FUNCTION_EXECUTE:
			/* Ignore these events. */
			break;
	}
}
Example #2
0
LRESULT core_win32::window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, bool& is_handled)
{
    switch (message)
    {
    case WM_CREATE:
        on_create();
        break;
    case WM_LAMBDA:
        on_lambda(reinterpret_cast<ui_task_type*>(lparam));
        break;
    case WM_SIZE:
        on_size(LOWORD(lparam), HIWORD(lparam), static_cast<int>(wparam));
        break;
    case WM_SETFOCUS:
    case WM_KILLFOCUS:
        on_focus_changed(message == WM_SETFOCUS);
        break;
    case WM_ENTERSIZEMOVE:
    case WM_EXITSIZEMOVE:
        on_enter_exit_sizemove(message == WM_ENTERSIZEMOVE);
        break;
    case WM_GETMINMAXINFO:
        on_get_minmax_info(reinterpret_cast<MINMAXINFO*>(lparam));
        break;
    case WM_DESTROY:
        on_destroy();
        break;
    default:
        is_handled = false;
        break;
    }
    return 0;
}
Example #3
0
static LRESULT CALLBACK
my_wndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_CREATE:
		on_create(hWnd);
		return 0;

	case WM_CLOSE:
		PostQuitMessage(0);
		break;

	case WM_CTLCOLORSTATIC:
		return on_ctlcolorstatic(hWnd, (HDC)wParam, (HWND)lParam);

	case WM_SIZE:
		on_size(hWnd, wParam, LOWORD(lParam), HIWORD(lParam));
		return 0;

	case WM_TIMER:
		if (wParam == WATCHDOG_TIMER) {
			on_watchdog_timer();
			return 0;
		}
		break;

	case M_PACKET:
		on_udp_packet();
		return 0;
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
Example #4
0
void
Window::set(ContainerWindow *parent, LPCTSTR cls, LPCTSTR text,
            int left, int top, unsigned width, unsigned height,
            DWORD style, DWORD ex_style)
{
#ifdef ENABLE_SDL
  this->parent = parent;
  this->left = left;
  this->top = top;
  canvas.set(width, height);

  if (parent != NULL)
    parent->add_child(*this);

  on_create();
#else /* !ENABLE_SDL */
  hWnd = ::CreateWindowEx(ex_style, cls, text, style,
                          left, top, width, height,
                          parent != NULL ? parent->hWnd : NULL,
                          NULL, XCSoarInterface::hInst, this);

  /* this isn't good error handling, but this only happens if
     out-of-memory (we can't do anything useful) or if we passed wrong
     arguments - which is a bug */
  assert(hWnd != NULL);
#endif /* !ENABLE_SDL */
}
Example #5
0
File: main.cpp Project: vadmium/aot
LRESULT CALLBACK wnd_proc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) {
    switch(msg)
    {
    case WM_CREATE:
        return on_create(hw);

    case WM_DESTROY:
        on_destroy(hw);
        break;

    case WM_CLOSE:
        on_close(hw);
        return 0;

    case WM_NOTIFY_ICON:
        return on_notify_icon(hw, lp);

        //~ case WM_COMMAND:
        //~ switch(LOWORD(wp))
        //~ {
        //~ case IDM_EXIT:
        //~ on_exit(hw);
        //~ break;
        //~ }
        //~ return 0;
    }

    return DefWindowProc(hw, msg, wp, lp);
}
Example #6
0
			LRESULT callback_main(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
			{
				//m_hWnd = hWnd;

				switch( msg )
				{
				case WM_CLOSE:	
					if ( on_close() )
						::DestroyWindow(hWnd);
					return 0;

				case WM_CREATE:	
					return ( on_create((::LPCREATESTRUCT)lParam) ? 0 : -1 );

				case WM_DESTROY:
					on_destroy();
					return 0;

				case WM_MOVE:
					on_move(LOWORD(lParam), HIWORD(lParam));
					return 0;

				case WM_SIZING:
					switch(wParam)
					{
					case WMSZ_LEFT:
						on_sizing(sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_RIGHT:
						on_sizing(sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					case WMSZ_TOP:
						on_sizing(sizing_hold_bit_top, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOM:
						on_sizing(sizing_hold_bit_bottom, (const LPRECT)lParam);
						break;
						
					case WMSZ_TOPLEFT:
						on_sizing(sizing_hold_bit_top | sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_TOPRIGHT:
						on_sizing(sizing_hold_bit_top | sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOMLEFT:
						on_sizing(sizing_hold_bit_bottom | sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOMRIGHT:
						on_sizing(sizing_hold_bit_bottom | sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					}
					return TRUE;
				}

				return ::DefWindowProc( hWnd, msg, wParam, lParam );
			}
Example #7
0
int main(int argc, char** argv)
{
  int fd, i;
  size_t src_size;
  size_t dst_size;
  struct inotify_event *evt;
  struct sigaction sa;
  int* watches;

  /* Read source file */
  if (argc != 2) {
    printf("Usage: %s <image to copy>\n", argv[0]);
    return 1;
  }

  if ((src_size = filesize(argv[1])) == -1) {
    return -1;
  }
  printf("Source Length: %lld\n", src_size);

  /* Create inotify watchlist for files created in /dev/disk/by-id */
  evt = (struct inotify_event*)alloca(sizeof(struct inotify_event) + NAME_MAX + 1);

  fd = inotify_init();

  if (fd == -1) {
    fprintf(stderr, "inotify_init() failed, aborting.\n");
    return 1;
  }

  if (inotify_add_watch(fd, dev_path, IN_CREATE) == -1) {
    perror("inotify_add_watch failed:");
    return 1;
  }

  /* Setup Signal Handler to cleanup after children */
  sa.sa_handler = SIG_DFL;
  sigemptyset(&sa.sa_mask);
  sa.sa_flags = SA_NOCLDWAIT;
  sa.sa_restorer = NULL;
  sigaction(SIGCHLD, &sa, NULL); 
  
  /* Respond to files created */
  while(1) {
    char* fname;
    read(fd, evt, sizeof(struct inotify_event) + NAME_MAX + 1);
    on_create(evt, argv[1], src_size);
  } 
  
  return 0;
}
Example #8
0
void
Window::set(ContainerWindow *parent, LPCTSTR cls, LPCTSTR text,
            int left, int top, unsigned width, unsigned height,
            bool center, bool notify, bool show,
            bool tabstop, bool border)
{
#ifdef ENABLE_SDL
  this->parent = parent;
  this->left = left;
  this->top = top;
  canvas.set(width, height);

  if (parent != NULL)
    parent->add_child(*this);

  on_create();
#else /* !ENABLE_SDL */
  DWORD ex_style = 0;
  DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

  if (parent == NULL)
    style |= WS_POPUP;
  else
    style |= WS_CHILD;

  if (show)
    style |= WS_VISIBLE;

  if (center)
    style |= SS_CENTER;

  if (notify)
    style |= SS_NOTIFY;

  if (tabstop)
    style |= WS_TABSTOP;

  if (border) {
    style |= WS_BORDER;

    if (model_is_hp31x()) {
      ex_style |= WS_EX_CLIENTEDGE;
      style |= WS_THICKFRAME;
    }
  }

  set(parent, cls, text, left, top, width, height, style, ex_style);
#endif /* !ENABLE_SDL */
}
Example #9
0
File: window.hpp Project: 8l/x11
      virtual void create()
	{
	  if ( ! m_window )
	    {

	      m_window = XCreateSimpleWindow ( m_display,
					       RootWindow((void*)m_display,0),
					       m_rect.origin().x(),
					       m_rect.origin().y(),
					       m_rect.width(),
					       m_rect.height(),
					       0,
					       WhitePixel((void*)m_display,0),
					       WhitePixel((void*)m_display,0));

	      set_background ( m_background );

	      if ( m_is_child )
		{

		  // keeps this window in front of its parent at all times
		  XSetTransientForHint ( m_display,
					 id(),
					 m_parent );

		  // make sure the app doesn't get killed when this
		  // window gets destroyed
		  m_atom[0] = XInternAtom ( m_display,
					    "WM_DELETE_WINDOW",
					    false );

		  XSetWMProtocols ( m_display,
				    m_window,
				    m_atom,
				    1 );
		}

	      if ( m_window == 0 )
		{
		}

	      on_create();

	    }

	  m_event_dispatcher.register_window ( this );

	}
Example #10
0
File: app.cpp Project: jj4jj/dcpots
int App::init(int argc, const char * argv[]){
    int ret = on_create(argc, argv);
    if (ret){
        GLOG_ERR("app check start error:%d !", ret);
        return -1;
    }
    ret = init_arguments(argc, argv, impl_, *this);
    if (ret){
        GLOG_ERR("init argumets error :%d !", ret);
        return -1;
    }
    _app_reload_env(impl_);
    //////////////////////////////////////////////////////////////
    const char * pidfile = cmdopt().getoptstr("pid-file");
    //1.control command
    ret = init_command(*this, pidfile);
    if (ret){
        if (ret < 0){
            GLOG_ERR("control command init error:%d !", ret);
            return -1;
        }
        else {
            exit(0);
        }
    }
    //"start:n:S:start process normal mode;"
    if (!cmdopt().hasopt("start")){
        exit(-1);
    }
    //2.daemonlization and pid running checking
    if (cmdopt().hasopt("daemon")){
        daemonlize(1, 0, pidfile);
    }
    if (pidfile && getpid() != dcs::lockpidfile(pidfile)){
        fprintf(stderr, "process should be unique running ...");
        return -2;
    }
    init_signal();
    //////////////////////////////////////////////////////////////
    ret = init_facilities(*this, impl_);
    if (ret){
        GLOG_ERR("init facilities error:%d !", ret);
        return -1;
    }
    GLOG_IFO("app framework init success !");
    //////////////////////////////////////////////////////////////////////////////////
    return on_init();
}
Example #11
0
         const value_type& emplace( Constructor&& c ) {
            auto new_id = _next_id;

            auto constructor = [&]( value_type& v ) {
               v.id = new_id;
               c( v );
            };

            auto insert_result = _indices.emplace( constructor, _indices.get_allocator() );

            if( !insert_result.second ) {
               BOOST_THROW_EXCEPTION( std::logic_error("could not insert object, most likely a uniqueness constraint was violated") );
            }

            ++_next_id;
            on_create( *insert_result.first );
            return *insert_result.first;
         }
Example #12
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    on_create();

    QThread *thread = new QThread( );
    Task    *task   = new Task();
    task->moveToThread(thread);
    connect( thread, SIGNAL(started()), task, SLOT(doWork()) );
    connect( task, SIGNAL(event_hotplug()), this, SLOT(event_hotplug()) );
    connect( task, SIGNAL(workFinished()), thread, SLOT(quit()) );
    //automatically delete thread and task object when work is done:
    connect( thread, SIGNAL(finished()), task, SLOT(deleteLater()) );
    connect( thread, SIGNAL(finished()), thread, SLOT(deleteLater()) );
    thread->start();
}
Example #13
0
	LRESULT CComWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
	{
		switch(uMsg)
		{
		case WM_INITDIALOG:		return on_create(m_hWnd, GetModuleHandle(0));
		case WM_VSCROLL: 
		case WM_HSCROLL:		return on_scroll(uMsg, wParam, lParam);
		case WM_SIZE:			
								__super::HandleMessage(uMsg, wParam, lParam, bHandled);
								return on_size(LOWORD(lParam), HIWORD(lParam));
		case WM_CLOSE:			return on_close();
		case WM_COMMAND:		return on_command(HWND(lParam), LOWORD(wParam), HIWORD(wParam));
		case WM_DEVICECHANGE:	return on_device_change(wParam, (DEV_BROADCAST_HDR*)lParam);
		case WM_SETTINGCHANGE:	return on_setting_change(wParam, LPCTSTR(lParam));
		case WM_CONTEXTMENU:	return on_contextmenu(HWND(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		case WM_LBUTTONDOWN:	return SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0);
		}
		if (uMsg >= WM_APP && uMsg <= 0xBFFF)
			return on_app(uMsg, wParam, lParam);

		return __super::HandleMessage(uMsg, wParam, lParam, bHandled);
	}
Example #14
0
static intptr_t CALLBACK
chatlist_proc(HWND window, uint32_t msg, uintptr_t w_param, intptr_t l_param)
{
	switch (msg) {

	case WM_CREATE:
		on_create(window);
		return 0;

	case WM_SIZE:
		on_size(window, LOWORD(l_param), HIWORD(l_param));
		return 0;

	case WM_NOTIFY: {
		NMHDR *note;

		note = (NMHDR *)l_param;

		if (note->idFrom != DLG_LIST)
			break;

		if (note->code == LVN_ITEMACTIVATE) {
			on_activate((NMITEMACTIVATE *)l_param);
			return 0;
		}
		if (note->code == NM_RCLICK) {
			on_right_click((NMITEMACTIVATE *)l_param);
			return 1;
		}
	}

	default:
		break;
	}

	return DefWindowProc(window, msg, w_param, l_param);
}
Example #15
0
afx_msg int kWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 on_create();
 return CWnd::OnCreate(lpCreateStruct);
}
Example #16
0
LRESULT
Window::on_message(HWND _hWnd, UINT message,
                       WPARAM wParam, LPARAM lParam)
{
  switch (message) {
  case WM_CREATE:
    return on_create() ? 0 : -1;
    break;

  case WM_DESTROY:
    if (on_destroy()) return 0;
    break;

  case WM_CLOSE:
    if (on_close())
      /* true returned: message was handled */
      return 0;
    break;

  case WM_SIZE:
    if (on_resize(LOWORD(lParam), HIWORD(lParam))) return 0;
    break;

  case WM_MOUSEMOVE:
    if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam))
      return 0;
    break;

  case WM_LBUTTONDOWN:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONUP:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONDBLCLK:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

#ifdef WM_MOUSEWHEEL
  case WM_MOUSEWHEEL:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_wheel(GET_WHEEL_DELTA_WPARAM(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;
#endif

  case WM_KEYDOWN:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_key_down(wParam)) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_KEYUP:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_key_up(wParam)) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_COMMAND:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_command(LOWORD(wParam), HIWORD(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_SETFOCUS:
    if (on_setfocus())
      return 0;
    break;

  case WM_KILLFOCUS:
    if (on_killfocus())
      return 0;
    break;

  case WM_TIMER:
    if (on_timer(wParam))
      return 0;
    break;
  }

  if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER))
    return 0;

  return on_unhandled_message(_hWnd, message, wParam, lParam);
}
Example #17
0
bool goal::redeploy(const config &cfg)
{
	cfg_ = cfg;
	on_create();
	return true;
}
Example #18
0
LRESULT
Window::on_message(HWND _hWnd, UINT message,
                       WPARAM wParam, LPARAM lParam)
{
  if (IsEmbedded() && !IsAltair()) {
    /* some older iPaqs such as the H3900 send only WM_KEYUP for
       VK_APP*, but never VK_KEYDOWN; the hx4700 has an additional set
       of undocumented key codes (0xca..0xcd) for the APP keys, but
       sends WM_KEYUP/VK_APP* additionally; the following rules
       hopefully catch all of these obscurities */
    if (message == WM_KEYUP && wParam >= 0x80)
      /* convert to WM_KEYDOWN to make all handlers catch it */
      message = WM_KEYDOWN;
    else if (message == WM_KEYDOWN && wParam >= 0x80)
      /* ignore the real WM_KEYDOWN, just in case it really happens */
      return 0;
  }

  switch (message) {
  case WM_CREATE:
    on_create();
    return 0;

  case WM_DESTROY:
    on_destroy();
    return 0;

  case WM_CLOSE:
    if (on_close())
      /* true returned: message was handled */
      return 0;
    break;

  case WM_SIZE:
    on_resize(LOWORD(lParam), HIWORD(lParam));
    return 0;

  case WM_MOUSEMOVE:
    if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam))
      return 0;
    break;

  case WM_LBUTTONDOWN:
    if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONUP:
    if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONDBLCLK:
    if (!double_clicks)
      /* instead of disabling CS_DBLCLKS (which would affect all
         instances of a window class), we just translate
         WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for
         built-in window class such as BUTTON */
      return on_message(_hWnd, WM_LBUTTONDOWN, wParam, lParam);

    if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }

    break;

#ifdef WM_MOUSEWHEEL
  case WM_MOUSEWHEEL:
    if (on_mouse_wheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                       GET_WHEEL_DELTA_WPARAM(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;
#endif

  case WM_KEYDOWN:
    if (on_key_down(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_KEYUP:
    if (on_key_up(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_COMMAND:
    if (on_command(LOWORD(wParam), HIWORD(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_CANCELMODE:
    if (on_cancel_mode())
      return 0;
    break;

  case WM_SETFOCUS:
    on_setfocus();
    return 0;

  case WM_KILLFOCUS:
    on_killfocus();
    return 0;

  case WM_TIMER:
    if (on_timer(*(WindowTimer *)wParam))
      return 0;
    break;

  case WM_PAINT:
    if (custom_painting) {
      PaintCanvas canvas(*this);
      on_paint(canvas, canvas.get_dirty());
      return 0;
    }
    break;

  case WM_GETDLGCODE:
    if (on_key_check(wParam))
      return DLGC_WANTMESSAGE;
    break;
  }

  if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER))
    return 0;

  return on_unhandled_message(_hWnd, message, wParam, lParam);
}
Example #19
0
afx_msg void kWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 on_create();
 CWnd::OnCreate(lpCreateStruct);
}