/**
     * Function called when an audio device is plugged or unplugged.
     *
     * @param event The property change event which may concern the audio device.
     */
    public void propertyChange(PropertyChangeEvent event) {
      if (DeviceConfiguration.PROP_AUDIO_SYSTEM_DEVICES.equals(event.getPropertyName())) {
        NotificationService notificationService = getNotificationService();

        if (notificationService != null) {
          // Registers only once to the  popup message notification
          // handler.
          if (!isRegisteredToPopupMessageListener) {
            isRegisteredToPopupMessageListener = true;
            managePopupMessageListenerRegistration(true);
          }

          // Fires the popup notification.
          ResourceManagementService resources = NeomediaActivator.getResources();
          Map<String, Object> extras = new HashMap<String, Object>();

          extras.put(NotificationData.POPUP_MESSAGE_HANDLER_TAG_EXTRA, this);
          notificationService.fireNotification(
              DEVICE_CONFIGURATION_HAS_CHANGED,
              resources.getI18NString("impl.media.configform" + ".AUDIO_DEVICE_CONFIG_CHANGED"),
              resources.getI18NString(
                  "impl.media.configform" + ".AUDIO_DEVICE_CONFIG_MANAGMENT_CLICK"),
              null,
              extras);
        }
      }
    }
示例#2
0
  /**
   * Upload files to pre-configured url.
   *
   * @param uploadLocation the location we are uploading to.
   * @param fileName the filename we use for the resulting filename we upload.
   * @param params the optional parameter names.
   * @param values the optional parameter values.
   */
  static void uploadLogs(String uploadLocation, String fileName, String[] params, String[] values) {
    try {
      File tempDir = LoggingUtilsActivator.getFileAccessService().getTemporaryDirectory();
      File newDest = new File(tempDir, fileName);

      File optionalFile = null;

      // if we have some description params
      // save them to file and add it to archive
      if (params != null) {
        optionalFile =
            new File(
                LoggingUtilsActivator.getFileAccessService().getTemporaryDirectory(),
                "description.txt");
        OutputStream out = new FileOutputStream(optionalFile);
        for (int i = 0; i < params.length; i++) {
          out.write((params[i] + " : " + values[i] + "\r\n").getBytes("UTF-8"));
        }
        out.flush();
        out.close();
      }

      newDest = LogsCollector.collectLogs(newDest, optionalFile);

      // don't leave any unneeded information
      if (optionalFile != null) optionalFile.delete();

      if (uploadLocation == null) return;

      if (HttpUtils.postFile(uploadLocation, "logs", newDest) != null) {
        NotificationService notificationService = LoggingUtilsActivator.getNotificationService();

        if (notificationService != null) {
          ResourceManagementService resources = LoggingUtilsActivator.getResourceService();
          String bodyMsgKey = "plugin.loggingutils.ARCHIVE_MESSAGE_OK";

          notificationService.fireNotification(
              LOGFILES_ARCHIVED,
              resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"),
              resources.getI18NString(bodyMsgKey, new String[] {uploadLocation}),
              null);
        }
      }
    } catch (Throwable e) {
      logger.error("Cannot upload file", e);
    }
  }
示例#3
0
  /**
   * Asks user for a location to save logs by poping up a file chooser. and archiving logs and
   * saving them on the specified location.
   */
  private void collectLogs() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    SipCommFileChooser fileChooser =
        GenericFileDialog.create(
            null,
            resources.getI18NString("plugin.loggingutils.ARCHIVE_FILECHOOSE_TITLE"),
            SipCommFileChooser.SAVE_FILE_OPERATION);
    fileChooser.setSelectionMode(SipCommFileChooser.SAVE_FILE_OPERATION);

    String defaultDir = "";
    try {
      defaultDir =
          LoggingUtilsActivator.getFileAccessService()
                  .getDefaultDownloadDirectory()
                  .getAbsolutePath()
              + File.separator;
    } catch (IOException ex) {
    }
    fileChooser.setStartPath(defaultDir + LogsCollector.getDefaultFileName());

    File dest = fileChooser.getFileFromDialog();

    if (dest == null) return;

    dest = LogsCollector.collectLogs(dest, null);

    NotificationService notificationService = LoggingUtilsActivator.getNotificationService();

    if (notificationService != null) {
      String bodyMsgKey =
          (dest == null)
              ? "plugin.loggingutils.ARCHIVE_MESSAGE_NOTOK"
              : "plugin.loggingutils.ARCHIVE_MESSAGE_OK";

      notificationService.fireNotification(
          LOGFILES_ARCHIVED,
          resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"),
          resources.getI18NString(bodyMsgKey, new String[] {dest.getAbsolutePath()}),
          null);
    }
  }
  /**
   * Returns the <tt>NotificationService</tt> obtained from the bundle context.
   *
   * @return The <tt>NotificationService</tt> obtained from the bundle context.
   */
  public static NotificationService getNotificationService() {
    if (notificationService == null) {
      // Get the notification service implementation
      ServiceReference notifReference =
          bundleContext.getServiceReference(NotificationService.class.getName());

      notificationService = (NotificationService) bundleContext.getService(notifReference);

      if (notificationService != null) {
        // Register a popup message for a device configuration changed
        // notification.
        notificationService.registerDefaultNotificationForEvent(
            DEVICE_CONFIGURATION_HAS_CHANGED,
            net.java.sip.communicator.service.notification.NotificationAction.ACTION_POPUP_MESSAGE,
            "Device onfiguration has changed",
            null);
      }
    }

    return notificationService;
  }