Exemplo n.º 1
0
static void
handle_player_set_media_message (SnraClient * client, GstStructure * s)
{
  const gchar *protocol, *path, *language;
  int port;
  gint64 tmp;

  protocol = gst_structure_get_string (s, "resource-protocol");
  path = gst_structure_get_string (s, "resource-path");

  if (protocol == NULL || path == NULL)
    return;                     /* Invalid message */

  if (!snra_json_structure_get_int (s, "resource-port", &port))
    return;

  if (!snra_json_structure_get_int64 (s, "base-time", &tmp))
    return;                     /* Invalid message */
  client->base_time = (GstClockTime) (tmp);

  if (!snra_json_structure_get_int64 (s, "position", &tmp))
    return;                     /* Invalid message */
  client->position = (GstClockTime) (tmp);

  if (!snra_json_structure_get_boolean (s, "paused", &client->paused))
    return;

  g_free (client->language);
  language = gst_structure_get_string (s, "language");
  client->language = g_strdup (language ? language : "en");

  g_free (client->uri);
  client->uri = g_strdup_printf ("%s://%s:%d%s", protocol,
      client->connected_server, port, path);

  if (client->enabled)
    set_media (client);

  g_object_notify (G_OBJECT (client), "language");
  g_object_notify (G_OBJECT (client), "media-uri");
}
Exemplo n.º 2
0
static void
handle_player_set_client_message (SnraClient * client, GstStructure * s)
{
  gboolean enabled;

  if (!snra_json_structure_get_boolean (s, "enabled", &enabled))
    return;

  if (enabled == client->enabled)
    return;
  client->enabled = enabled;

  if (!client->player)
    return;

  if (client->enabled && client->uri)
    set_media (client);
  else
    gst_element_set_state (GST_ELEMENT (client->player), GST_STATE_NULL);

  g_object_notify (G_OBJECT (client), "enabled");
}
Exemplo n.º 3
0
/* Update the free space on the device */
bool DEVICE::update_freespace() 
{
   POOL_MEM ocmd(PM_FNAME);
   POOLMEM* results;
   char* icmd;
   int timeout;
   uint64_t free;
   char ed1[50];
   bool ok = false;
   int status;

   if (!is_dvd() || is_freespace_ok()) {
      return true;
   }
   
   /* The device must be mounted in order to dvd-freespace to work */
   mount(1);
   
   Dsm_check(400);
   icmd = device->free_space_command;
   
   if (!icmd) {
      free_space = 0;
      free_space_errno = 0;
      clear_freespace_ok();              /* No valid freespace */
      clear_media();
      Dmsg2(29, "ERROR: update_free_space_dev: free_space=%s, free_space_errno=%d (!icmd)\n", 
            edit_uint64(free_space, ed1), free_space_errno);
      Mmsg(errmsg, _("No FreeSpace command defined.\n"));
      return false;
   }
   
   edit_mount_codes(ocmd, icmd);
   
   Dmsg1(29, "update_freespace: cmd=%s\n", ocmd.c_str());

   results = get_pool_memory(PM_MESSAGE);
   
   /* Try at most 3 times to get the free space on the device. This should perhaps be configurable. */
   timeout = 3;
   
   while (1) {
      berrno be;
      Dmsg1(20, "Run freespace prog=%s\n", ocmd.c_str());
      status = run_program_full_output(ocmd.c_str(), max_open_wait/2, results);
      Dmsg2(500, "Freespace status=%d result=%s\n", status, results);
      if (status == 0) {
         free = str_to_int64(results);
         Dmsg1(400, "Free space program run: Freespace=%s\n", results);
         if (free >= 0) {
            free_space = free;
            free_space_errno = 0;
            set_freespace_ok();     /* have valid freespace */
            set_media();
            Mmsg(errmsg, "");
            ok = true;
            break;
         }
      }
      free_space = 0;
      free_space_errno = EPIPE;
      clear_freespace_ok();         /* no valid freespace */
      Mmsg2(errmsg, _("Cannot run free space command. Results=%s ERR=%s\n"), 
            results, be.bstrerror(status));
      
      if (--timeout > 0) {
         Dmsg4(40, "Cannot get free space on device %s. free_space=%s, "
            "free_space_errno=%d ERR=%s\n", print_name(), 
               edit_uint64(free_space, ed1), free_space_errno, 
               errmsg);
         bmicrosleep(1, 0);
         continue;
      }

      dev_errno = free_space_errno;
      Dmsg4(40, "Cannot get free space on device %s. free_space=%s, "
         "free_space_errno=%d ERR=%s\n",
            print_name(), edit_uint64(free_space, ed1),
            free_space_errno, errmsg);
      break;
   }
   
   free_pool_memory(results);
   Dmsg4(29, "leave update_freespace: free_space=%s freespace_ok=%d free_space_errno=%d have_media=%d\n", 
      edit_uint64(free_space, ed1), !!is_freespace_ok(), free_space_errno, !!have_media());
   Dsm_check(400);
   return ok;
}
Exemplo n.º 4
0
void handle_code_actuate(const uint8_t code, const uint8_t action, const uint8_t tapkey)
{
	const uint8_t modaction = (action & MOD_ACTION_MASK);
	
	if (modaction)
	{
		g_autokey_modifier = modaction;
	}
	
	switch(code)
	{
	case HID_KEYBOARD_SC_A:
	case HID_KEYBOARD_SC_B:
	case HID_KEYBOARD_SC_C:
	case HID_KEYBOARD_SC_D:
	case HID_KEYBOARD_SC_E:
	case HID_KEYBOARD_SC_F:
	case HID_KEYBOARD_SC_G:
	case HID_KEYBOARD_SC_H:
	case HID_KEYBOARD_SC_I:
	case HID_KEYBOARD_SC_J:
	case HID_KEYBOARD_SC_K:
	case HID_KEYBOARD_SC_L:
	case HID_KEYBOARD_SC_M:
	case HID_KEYBOARD_SC_N:
	case HID_KEYBOARD_SC_O:
	case HID_KEYBOARD_SC_P:
	case HID_KEYBOARD_SC_Q:
	case HID_KEYBOARD_SC_R:
	case HID_KEYBOARD_SC_S:
	case HID_KEYBOARD_SC_T:
	case HID_KEYBOARD_SC_U:
	case HID_KEYBOARD_SC_V:
	case HID_KEYBOARD_SC_W:
	case HID_KEYBOARD_SC_X:
	case HID_KEYBOARD_SC_Y:
	case HID_KEYBOARD_SC_Z:
	case HID_KEYBOARD_SC_1_AND_EXCLAMATION:
	case HID_KEYBOARD_SC_2_AND_AT:
	case HID_KEYBOARD_SC_3_AND_HASHMARK:
	case HID_KEYBOARD_SC_4_AND_DOLLAR:
	case HID_KEYBOARD_SC_5_AND_PERCENTAGE:
	case HID_KEYBOARD_SC_6_AND_CARET:
	case HID_KEYBOARD_SC_7_AND_AMPERSAND:
	case HID_KEYBOARD_SC_8_AND_ASTERISK:
	case HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS:
	case HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS:
	case HID_KEYBOARD_SC_ENTER:
	case HID_KEYBOARD_SC_ESCAPE:
	case HID_KEYBOARD_SC_BACKSPACE:
	case HID_KEYBOARD_SC_TAB:
	case HID_KEYBOARD_SC_SPACE:
	case HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE:
	case HID_KEYBOARD_SC_EQUAL_AND_PLUS:
	case HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE:
	case HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE:
	case HID_KEYBOARD_SC_BACKSLASH_AND_PIPE:
	case HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE:
	case HID_KEYBOARD_SC_SEMICOLON_AND_COLON:
	case HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE:
	case HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE:
	case HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN:
	case HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN:
	case HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK:
	case HID_KEYBOARD_SC_CAPS_LOCK:
	case HID_KEYBOARD_SC_F1:
	case HID_KEYBOARD_SC_F2:
	case HID_KEYBOARD_SC_F3:
	case HID_KEYBOARD_SC_F4:
	case HID_KEYBOARD_SC_F5:
	case HID_KEYBOARD_SC_F6:
	case HID_KEYBOARD_SC_F7:
	case HID_KEYBOARD_SC_F8:
	case HID_KEYBOARD_SC_F9:
	case HID_KEYBOARD_SC_F10:
	case HID_KEYBOARD_SC_F11:
	case HID_KEYBOARD_SC_F12:
	case HID_KEYBOARD_SC_PRINT_SCREEN:
	case HID_KEYBOARD_SC_SCROLL_LOCK:
	case HID_KEYBOARD_SC_PAUSE:
	case HID_KEYBOARD_SC_INSERT:
	case HID_KEYBOARD_SC_HOME:
	case HID_KEYBOARD_SC_PAGE_UP:
	case HID_KEYBOARD_SC_DELETE:
	case HID_KEYBOARD_SC_END:
	case HID_KEYBOARD_SC_PAGE_DOWN:
	case HID_KEYBOARD_SC_RIGHT_ARROW:
	case HID_KEYBOARD_SC_LEFT_ARROW:
	case HID_KEYBOARD_SC_DOWN_ARROW:
	case HID_KEYBOARD_SC_UP_ARROW:
	case HID_KEYBOARD_SC_NUM_LOCK:
	case HID_KEYBOARD_SC_KEYPAD_SLASH:
	case HID_KEYBOARD_SC_KEYPAD_ASTERISK:
	case HID_KEYBOARD_SC_KEYPAD_MINUS:
	case HID_KEYBOARD_SC_KEYPAD_PLUS:
	case HID_KEYBOARD_SC_KEYPAD_ENTER:
	case HID_KEYBOARD_SC_KEYPAD_1_AND_END:
	case HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW:
	case HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN:
	case HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW:
	case HID_KEYBOARD_SC_KEYPAD_5:
	case HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW:
	case HID_KEYBOARD_SC_KEYPAD_7_AND_HOME:
	case HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW:
	case HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP:
	case HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT:
	case HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE:
	case HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE:
	case HID_KEYBOARD_SC_APPLICATION:
	case HID_KEYBOARD_SC_POWER:
	case HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN:
	case HID_KEYBOARD_SC_F13:
	case HID_KEYBOARD_SC_F14:
	case HID_KEYBOARD_SC_F15:
	case HID_KEYBOARD_SC_F16:
	case HID_KEYBOARD_SC_F17:
	case HID_KEYBOARD_SC_F18:
	case HID_KEYBOARD_SC_F19:
	case HID_KEYBOARD_SC_F20:
	case HID_KEYBOARD_SC_F21:
	case HID_KEYBOARD_SC_F22:
	case HID_KEYBOARD_SC_F23:
	case HID_KEYBOARD_SC_F24:
#ifdef MACRO_RAM_SIZE
		if (g_recording_macro)
			record_stroke(code);
#endif /* MACRO_RAM_SIZE */
		alpha_down(code, action);
		break;
	case HID_KEYBOARD_SC_LOCKING_CAPS_LOCK:
		queue_autokeys(HID_KEYBOARD_SC_CAPS_LOCK, g_modifier_state);
		break;
	case HID_KEYBOARD_SC_LOCKING_NUM_LOCK:
		queue_autokeys(HID_KEYBOARD_SC_NUM_LOCK, g_modifier_state);
		break;
	case HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK:
		queue_autokeys(HID_KEYBOARD_SC_SCROLL_LOCK, g_modifier_state);
		break;
#ifdef MAX_NUMBER_OF_BACKLIGHTS
	case SCANCODE_BL_DIMMER:
		backlight_dimmer();
		break;
	case SCANCODE_BL_MODE:
		backlight_mode();
		break;
	case SCANCODE_BL_ENABLE:
		backlight_enable();
		break;
#else
	case SCANCODE_BL_DIMMER:
		led_dimmer();
		break;
#endif /* MAX_NUMBER_OF_BACKLIGHTS */
#ifdef MACRO_RAM_SIZE
	case SCANCODE_PASSWORD1:
	case SCANCODE_PASSWORD2:
	case SCANCODE_PASSWORD3:
	case SCANCODE_PASSWORD4:
		if (!g_recording_macro)
			start_password_record(code);
		break;
#endif /* MACRO_RAM_SIZE */
	case SCANCODE_KEYLOCK:
		g_keylock_flag ^= 1;
		break;
	case SCANCODE_WINLOCK:
		g_winlock_flag ^= 1;
		if (g_winlock_flag == 0)
			led_host_off(LED_WIN_LOCK);
		else
			led_host_on(LED_WIN_LOCK);
		break;
	case SCANCODE_ESCGRAVE:
		break;
	case SCANCODE_BOOT:
		g_reset_requested = RESET_TO_BOOT;
		break;
	case SCANCODE_CONFIG:
		if (g_console_state == CONSOLE_IDLE)
			g_console_state = CONSOLE_MENU_MAIN;
		break;
	case SCANCODE_MUTE:
	case SCANCODE_VOL_INC:
	case SCANCODE_VOL_DEC:
	case SCANCODE_BASS_BOOST:
	case SCANCODE_NEXT_TRACK:
	case SCANCODE_PREV_TRACK:
	case SCANCODE_STOP:
	case SCANCODE_PLAY_PAUSE:
	case SCANCODE_BACK:
	case SCANCODE_FORWARD:
	case SCANCODE_MEDIA:
	case SCANCODE_MAIL:
	case SCANCODE_CALC:
	case SCANCODE_MYCOMP:
	case SCANCODE_SEARCH:
	case SCANCODE_BROWSER:
		set_media(code);
		break;
#ifdef ENABLE_MOUSE
	case SCANCODE_MOUSE1:
	case SCANCODE_MOUSE2:
	case SCANCODE_MOUSE3:
	case SCANCODE_MOUSE4:
	case SCANCODE_MOUSE5:
		set_mousebutton(code);
		break;
	case SCANCODE_MOUSEXR:
		g_mouse_req_X++;
		goto mousemove;
	case SCANCODE_MOUSEXL:
		g_mouse_req_X--;
		goto mousemove;
	case SCANCODE_MOUSEYU:
		g_mouse_req_Y--;
		goto mousemove;
	case SCANCODE_MOUSEYD:
		g_mouse_req_Y++;
	mousemove:
		if ((g_mouse_active == 0) || (g_mouse_multiply < g_double_tap_repeat))
			g_mouse_multiply = g_double_tap_repeat;
		break;
#endif /* ENABLE_MOUSE */
	case SCANCODE_M1:
	case SCANCODE_M2:
	case SCANCODE_M3:
	case SCANCODE_M4:
	case SCANCODE_M5:
	case SCANCODE_M6:
	case SCANCODE_M7:
	case SCANCODE_M8:
	case SCANCODE_M9:
	case SCANCODE_M10:
	case SCANCODE_M11:
	case SCANCODE_M12:
	case SCANCODE_M13:
	case SCANCODE_M14:
		play_macro(code);
		break;
#ifdef MACRO_RAM_SIZE
	case SCANCODE_MRAM_RECORD:
		toggle_macro_record();
		break;
	case SCANCODE_MRAM_PLAY:
		if (!g_recording_macro)
			queue_ram_macro(g_ram_macro, g_ram_macro_length);
		break;
#endif /* MACRO_RAM_SIZE */
	case HID_KEYBOARD_SC_LEFT_CONTROL:
	case HID_KEYBOARD_SC_LEFT_SHIFT:
	case HID_KEYBOARD_SC_LEFT_ALT:
	case HID_KEYBOARD_SC_LEFT_GUI:
	case HID_KEYBOARD_SC_RIGHT_CONTROL:
	case HID_KEYBOARD_SC_RIGHT_SHIFT:
	case HID_KEYBOARD_SC_RIGHT_ALT:
	case HID_KEYBOARD_SC_RIGHT_GUI:
		mod_down(code, action);
		break;
	case SCANCODE_FN:
	case SCANCODE_FN2:
	case SCANCODE_FN3:
	case SCANCODE_FN4:
	case SCANCODE_FN5:
	case SCANCODE_FN6:
	case SCANCODE_FN7:
	case SCANCODE_FN8:
	case SCANCODE_FN9:
		fn_down(code, action);
		break;
	default:
		report_event(EVENT_CODE_KEYMAP_INVALID_CODE, code, MODE_UPDATE);
		break;
	}
	
	g_last_keypress = code;
}