author Gregory Szorc <>
Tue, 24 Feb 2015 15:16:54 -0800
changeset 245746 6d143a910f5ecf67d9dec302087aa20777ec6772
parent 230422 c2aabf638fb48ad347ae6a78c5d901050216c945
child 310814 79e6642642bb6617dbe9edff793556d99d4638b4
child 310968 37ce9e6af14e6a712b14395c6ee073c10defda6d
permissions -rw-r--r--
Bug 1132771 - Add Files to with ability to define Bugzilla component The Files sub-context allows us to attach metadata to files based on pattern matching rules. Patterns are matched against files in a last-write-wins fashion. The sub-context defines the BUG_COMPONENT variable, which is a 2-tuple (actually a named tuple) defining the Bugzilla product and component for files. There are no consumers yet. But an eventual use case will be to suggest a bug component for a patch/commit. Another will be to automatically suggest a bug component for a failing test.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef nsAlertsIconListener_h__
#define nsAlertsIconListener_h__

#include "nsCOMPtr.h"
#include "imgINotificationObserver.h"
#include "nsStringAPI.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"

#include <gdk-pixbuf/gdk-pixbuf.h>

class imgIRequest;

struct NotifyNotification;

class nsAlertsIconListener : public imgINotificationObserver,
                             public nsIObserver,
                             public nsSupportsWeakReference


  nsresult InitAlertAsync(const nsAString & aImageUrl,
                          const nsAString & aAlertTitle, 
                          const nsAString & aAlertText,
                          bool aAlertTextClickable,
                          const nsAString & aAlertCookie,
                          nsIObserver * aAlertListener,
                          bool aInPrivateBrowsing);

  void SendCallback();
  void SendClosed();

  virtual ~nsAlertsIconListener();

  nsresult OnLoadComplete(imgIRequest* aRequest);
  nsresult OnFrameComplete(imgIRequest* aRequest);

   * The only difference between and for these symbols
   * is that notify_notification_new takes three arguments in and
   * four in
   * Passing the fourth argument as NULL is binary compatible.
  typedef void (*NotifyActionCallback)(NotifyNotification*, char*, gpointer);
  typedef bool (*notify_is_initted_t)(void);
  typedef bool (*notify_init_t)(const char*);
  typedef GList* (*notify_get_server_caps_t)(void);
  typedef NotifyNotification* (*notify_notification_new_t)(const char*, const char*, const char*, const char*);
  typedef bool (*notify_notification_show_t)(void*, char*);
  typedef void (*notify_notification_set_icon_from_pixbuf_t)(void*, GdkPixbuf*);
  typedef void (*notify_notification_add_action_t)(void*, const char*, const char*, NotifyActionCallback, gpointer, GFreeFunc);

  nsCOMPtr<imgIRequest> mIconRequest;
  nsCString mAlertTitle;
  nsCString mAlertText;

  nsCOMPtr<nsIObserver> mAlertListener;
  nsString mAlertCookie;

  bool mLoadedFrame;
  bool mAlertHasAction;

  static void* libNotifyHandle;
  static bool libNotifyNotAvail;
  static notify_is_initted_t notify_is_initted;
  static notify_init_t notify_init;
  static notify_get_server_caps_t notify_get_server_caps;
  static notify_notification_new_t notify_notification_new;
  static notify_notification_show_t notify_notification_show;
  static notify_notification_set_icon_from_pixbuf_t notify_notification_set_icon_from_pixbuf;
  static notify_notification_add_action_t notify_notification_add_action;
  NotifyNotification* mNotification;
  gulong mClosureHandler;

  nsresult StartRequest(const nsAString & aImageUrl, bool aInPrivateBrowsing);
  nsresult ShowAlert(GdkPixbuf* aPixbuf);