Example #1
0
VALUE executeRestore(VALUE self, VALUE manager)
{
   ManagerHandle *handle = NULL;
   char          *buffer = NULL;
   short         length  = 0;
   ISC_STATUS    status[20];

   /* Check that the service manager is connected. */
   Data_Get_Struct(manager, ManagerHandle, handle);
   if(handle->handle == 0)
   {
      rb_ibruby_raise(NULL,
                        "Database restore error. Service manager not connected.");
   }

   createRestoreBuffer(rb_iv_get(self, "@backup_file"),
                       rb_iv_get(self, "@database"),
                       rb_iv_get(self, "@options"), &buffer, &length);

   /* Start the service request. */
   if(isc_service_start(status, &handle->handle, NULL, length, buffer))
   {
      free(buffer);
      rb_ibruby_raise(status, "Error performing database restore.");
   }
   free(buffer);

   /* Query the service until it is complete. */
   rb_iv_set(self, "@log", queryService(&handle->handle));

   return(self);
}
Example #2
0
/*
 *  Respond to monitor icon events
 */
static int monitorEvent(HWND hwnd, WPARAM wp, LPARAM lp)
{
    RECT            windowRect;
    POINT           p, pos;
    HWND            h;
    char            textBuf[48];
    uint            msg;
    int             state;

    msg = (uint) lp;

    /*
     *  Show the menu on single right click
     */
    if (msg == WM_RBUTTONUP) {
        state = queryService();

        if (state < 0 || state & SERVICE_STOPPED) {
            mprSprintf(textBuf, sizeof(textBuf), "%s Stopped", BLD_NAME);
            updateMenu(MA_MENU_STATUS, textBuf, 0, -1);
            updateMenu(MA_MENU_START, 0, 1, 0);
            updateMenu(MA_MENU_STOP, 0, -1, 0);
        } else {
            mprSprintf(textBuf, sizeof(textBuf), "%s Running", BLD_NAME);
            updateMenu(MA_MENU_STATUS, textBuf, 0, 1);
            updateMenu(MA_MENU_START, 0, -1, 0);
            updateMenu(MA_MENU_STOP, 0, 1, 0);
        }

        /*
         *  Popup the context menu. Position near the bottom of the screen
         */
        h = GetDesktopWindow();
        GetWindowRect(h, &windowRect);
        GetCursorPos(&pos);

        p.x = pos.x;
        p.y = windowRect.bottom - 20;

        SetForegroundWindow(appHwnd);
        TrackPopupMenu(subMenu, TPM_RIGHTALIGN | TPM_RIGHTBUTTON, p.x, p.y, 0, appHwnd, NULL);
        /* Required Windows work-around */
        PostMessage(appHwnd, WM_NULL, 0, 0);

        return 0;
    }

    /*
     *  Launch the Appweb Monitor Manager on a double click
     */
    if (msg == WM_LBUTTONDBLCLK) {
        runBrowser("/index.html");
        return 0;
    }
    return 1;
}