Esempio n. 1
4
		public override void AskYesNoQuestion (string title, string message, Gdk.Pixbuf icon,
				string ok_string, string cancel_string,
				EventHandler ok_handler, EventHandler cancel_handler)
		{
			Notification notify = new Notification (title, message, icon);
			notify.Timeout = 60000;

			notify.AddAction (cancel_string, cancel_string, delegate {
					if (cancel_handler != null)
						cancel_handler (null, null);
					currentNotification = null;
				});

			notify.AddAction (ok_string, ok_string, delegate {
					if (ok_handler != null)
						ok_handler (null, null);
					currentNotification = null;
				});

			notify.Closed += delegate {
					if (cancel_handler != null)
						cancel_handler (null, null);
					currentNotification = null;
				};

			if (currentNotification != null) {
				Logger.Debug ("RECEIVE: HandleSendRequest: Found a notification... closing it");
				currentNotification.Close();
				currentNotification = null;
			}

			currentNotification = notify;
			currentNotification.Show ();
		}
Esempio n. 2
2
        public PryanetBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                if (!Program.Controller.NotificationsEnabled)
                    return;

                try {
                    Notification notification = new Notification () {
                        Summary = title,
                        Body    = subtext,
                        Timeout = 5 * 1000,
                        Urgency = Urgency.Low
                    };

                    if (image_path != null)
                        notification.Icon = new Gdk.Pixbuf (image_path);
                    else
                        notification.IconName = "folder-pryanetshare";

                    notification.Closed += delegate (object o, EventArgs args) {
                        if ((args as CloseArgs).Reason == CloseReason.User)
                            Controller.BubbleClicked ();
                    };

                    notification.Show ();

                } catch (Exception e) {
                    PryanetLogger.LogInfo ("Notification", "Error showing notification: ", e);
                }
            };
        }
Esempio n. 3
1
    public Notifier ()
    {
      _enabled = true;
      _queue = new Queue<NotificationMessage> ();
      _sync = ((ICollection) _queue).SyncRoot;
      _waitHandle = new ManualResetEvent (false);

      ThreadPool.QueueUserWorkItem (
        state => {
          while (_enabled || Count > 0) {
            var msg = dequeue ();
            if (msg != null) {
#if UBUNTU
              var nf = new Notification (msg.Summary, msg.Body, msg.Icon);
              nf.AddHint ("append", "allowed");
              nf.Show ();
#else
              Console.WriteLine (msg);
#endif
            }
            else {
              Thread.Sleep (500);
            }
          }

          _waitHandle.Set ();
        });
    }
        public SparkleBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                try {
                    Notification notification = new Notification () {
                        Summary = title,
                        Body    = subtext,
                        Timeout = 5 * 1000,
                        Urgency = Urgency.Low
                    };

                    if (image_path != null)
                        notification.Icon = new Gdk.Pixbuf (image_path);
                    else
                        notification.IconName = "folder-sparkleshare";

                    notification.Closed += delegate (object o, EventArgs args) {
                        if ((args as CloseArgs).Reason == CloseReason.User)
                            Controller.BubbleClicked ();
                    };

                    notification.Show ();

                } catch (Exception) {
                    // Ignore exceptions thrown by libnotify,
                    // they're not important enough to crash
                }
            };
        }
Esempio n. 5
0
        public SparkleBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                try {
                    Notification notification = new Notification () {
                        Timeout  = 5 * 1000,
                        Urgency  = Urgency.Low
                    };

                    if (image_path != null)
                        notification.Icon = new Gdk.Pixbuf (image_path);
                    else
                        notification.IconName = "folder-sparkleshare";

                    notification.Closed += delegate {
                        Application.Invoke (delegate {
                            if (SparkleUI.EventLog == null)
                                SparkleUI.EventLog = new SparkleEventLog ();

                            SparkleUI.EventLog.Controller.SelectedFolder = null;

                            SparkleUI.EventLog.ShowAll ();
                            SparkleUI.EventLog.Present ();
                        });
                    };

                    notification.Show ();

                } catch (Exception) {
                    // Ignore exceptions thrown by libnotify,
                    // they're not important enough to crash
                }
            };
        }
Esempio n. 6
0
        public static LibNotify.Notification Notify(string title, string message, string icon)
        {
            try {
                LibNotify.Notification notify = ToNotify(title, message, icon);

                // if we aren't using notify-osd, show a status icon
                if (!ServerIsNotifyOSD())
                {
                    DockServices.System.RunOnMainThread(() => statusIcon.Visible = true);

                    notify.Closed += delegate {
                        DockServices.System.RunOnMainThread(() => statusIcon.Visible = false);
                    };
                }

                notify.Show();

                return(notify);
            } catch (Exception e) {
                Log <NotificationService> .Warn("Error showing notification: {0}", e.Message);

                Log <NotificationService> .Debug(e.StackTrace);

                return(null);
            }
        }
Esempio n. 7
0
 internal static void SendReport(string from_email, string to_email, string subject, string message, DateTime today)
 {
     try
     {
         TaskSettings settings = new TaskSettings();
         settings = settings.Load();
         MailAddress from_address = new MailAddress(from_email, settings.name);
         MailAddress to_address = new MailAddress(to_email);
         MailMessage mail = new MailMessage(from_address, to_address);
         string date = today.Year + "-" + today.Month + "-" + today.Day;
         mail.Subject = subject.Replace("<Date>", date);
         mail.Body = message;
         SmtpClient smtpclient = new SmtpClient(settings.smtpServer);
         smtpclient.Credentials = new NetworkCredential(settings.email, settings.password);
         smtpclient.EnableSsl = true;
         smtpclient.Port = Convert.ToInt32(settings.smtpport);
         smtpclient.Send(mail);
     }
     catch (Exception e)
     {
         Notification notify = new Notification("Task Tracker: " + e.Message, "");
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
 }
Esempio n. 8
0
        private void ShowBubbleEvent (string title, string subtext, string image_path)
        {
            if (!Program.Controller.NotificationsEnabled)
                return;

			Application.Invoke (delegate {
				Notification notification = new Notification () {
					Summary = title,
					Body    = subtext,
					Timeout = 5 * 1000,
					Urgency = Urgency.Low
				};

				if (image_path != null)
					notification.Icon = new Gdk.Pixbuf (image_path);
				else
					notification.IconName = "folder-sparkleshare";

				try {
					notification.Show ();

				} catch (Exception e) {
					SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e);
				}
			});
        }
Esempio n. 9
0
        LibNotify.Notification ToNotify(Notification note)
        {
            LibNotify.Notification notify = new LibNotify.Notification();
            notify.Body    = GLib.Markup.EscapeText(note.Body);
            notify.Summary = GLib.Markup.EscapeText(note.Title);
            notify.Closed += (sender, e) => OnNotificationClosed(note);
            notify.Timeout = ReadableDurationForMessage(note.Title, note.Body);

            if (SupportsCapability(NotificationCapability.scaling) && !note.Icon.Contains("@"))
            {
                notify.IconName = string.IsNullOrEmpty(note.Icon)
                                        ? DefaultIconName
                                        : note.Icon;
            }
            else
            {
                notify.Icon = string.IsNullOrEmpty(note.Icon)
                                        ? DefaultIcon
                                        : IconProvider.PixbufFromIconName(note.Icon, IconSize);
            }

            if (note is ActionableNotification)
            {
                ActionableNotification anote = note as ActionableNotification;
                notify.AddAction(GLib.Markup.EscapeText(anote.ActionLabel),
                                 anote.ActionLabel, (sender, e) => anote.PerformAction());
            }

            return(notify);
        }
Esempio n. 10
0
 internal static void SuggestTask()
 {
     SetPidginStatus("Available", "");
     Notification notify;
     Tasks tasks = new Tasks();
     tasks.Load();
     Task task = tasks.GetPriority();
     if (task != null)
     {
         notify = new Notification("Tasks", "This is the next priority task:\n" + task.Summary);
         notify.AddAction("select", "Select", HandleSelectTask);
         notify.AddAction("postpone", "Delay", HandlePostponeTask);
         notify.AddAction("AddTask", "Add Task", HandleAddTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
     else
     {
         notify = new Notification("Tasks", "What are you working on?");
         notify.AddAction("AddTask", "Add Task", HandleAddTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
 }
Esempio n. 11
0
        public static void Main(string[] args)
        {
            /*Application.Init ();
             * //MainWindow win = new MainWindow ();
             * win = new MainWindow ();
             *
             *
             * win.setHint();
             *
             *
             *
             * // Gdk.WindowType.Utility
             * win.Show ();
             * Application.Run ();
             */

            Mono.Unix.Catalog.Init("lliurex-miniscreen", "/usr/share/locale");

            Application.Init();
            LliureXMiniScreen.Core.getCore();
            LliureXMiniScreen.Core.getCore().win.setHint();

            string sumary = "LliureX MiniScreen";
            string body   = Mono.Unix.Catalog.GetString("To Quit, press right button on MiniScreen and select Quit.");
            /*string icon="/usr/share/icons/LliureX-Accessibility/Lliurex-MiniScreen.png";*/
            string icon = "lliurex-miniscreen";

            Notifications.Notification note = new Notifications.Notification(sumary, body, icon);

            note.Show();
            Application.Run();
        }
Esempio n. 12
0
        public static void Main(string[] args)
        {
            //using (WebSocket ws = new WebSocket("ws://localhost:8000/"))
              using (WebSocket ws = new WebSocket("ws://localhost:8000/", "chat"))
              {
            /*ws.OnOpen += (o, e) =>
            {
              //Do something.
            };
             */
            ws.OnMessage += (o, s) =>
            {
            #if NOTIFY
              Notification nf = new Notification("[WebSocket] Message",
                                             s,
                                             "notification-message-im");
              nf.AddHint("append", "allowed");
              nf.Show();
            #else
              Console.WriteLine("[WebSocket] Message: {0}", s);
            #endif
            };

            ws.OnError += (o, s) =>
            {
              Console.WriteLine("[WebSocket] Error  : {0}", s);
            };

            /*ws.OnClose += (o, e) =>
            {
              //Do something.
            };
             */
            ws.Connect();

            Thread.Sleep(500);
            Console.WriteLine("\nType \"exit\" to exit.\n");

            string data;
            while (true)
            {
              Thread.Sleep(500);

              Console.Write("> ");
              data = Console.ReadLine();
              if (data == "exit")
              {
            break;
              }

              ws.Send(data);
            }
              }
        }
Esempio n. 13
0
 static void Daily()
 {
     Reports dailyreport = new Reports();
     dailyreportmessage = dailyreport.CompileDailyReport(selected);
     Notification notify = new Notification();
     notify.Summary = "Daily Report " + selected.ToShortDateString();
     notify.Body = dailyreportmessage;
     notify.AddAction("send", "Send", HandleSendReport);
     notify.Urgency = Urgency.Critical;
     notify.Show();
 }
Esempio n. 14
0
        private void OnShowNotificationExecute()
        {
            var notification = new Notification
            {
                Title = NotificationTitle,
                Message = NotificationMessage,
                Command = new TaskCommand(async () => await _messageService.ShowAsync("You just clicked a notification")),
                IsClosable = IsClosable
            };

            _notificationService.ShowNotification(notification);
        }
Esempio n. 15
0
 static void HandleDailyReportActivated(object sender, EventArgs e)
 {
     Reports dailyreport = new Reports();
     dailyreportmessage = dailyreport.CompileDailyReport();
     Notification notify = new Notification();
     notify.Summary = "Daily Report";
     notify.Body = dailyreportmessage;
     notify.AddAction("send", "Send", HandleSendDaily);
     notify.AddAction("select", "Select Date", HandleSelectedReportActivated);
     notify.Urgency = Urgency.Critical;
     notify.Show();
 }
Esempio n. 16
0
        public SysTrayIcon(XbmControlEvo parent)
        {
            _parent 			= parent;

            this.siTray 			= new StatusIcon(this._parent.oImages.menu.icon);
            this.siTray.Visible 	= true;
            this.siTray.Activate 	+= OnActivate;
            this.siTray.PopupMenu 	+= OnTrayIconPopup;
            this.siTray.Tooltip 	= "XBMControl Evo";
            this.balloonTip			= new Notification();

            //ShowBallonTip();
        }
Esempio n. 17
0
        public SparkleBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                Notification notification = new Notification () {
                    Timeout  = 5 * 1000,
                    Urgency  = Urgency.Low
                };

                if (image_path != null)
                    notification.Icon = new Gdk.Pixbuf (image_path);
                else
                    notification.IconName = "folder-sparkleshare";

                notification.Show ();
            };
        }
Esempio n. 18
0
        public SparkleBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                if (!Program.Controller.NotificationsEnabled)
                    return;

                try {
                    // Debug information for https://github.com/hbons/SparkleShare/issues/1362
                    if (title.Length > 255) {
                        SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'title'");
                        title = title.Substring (0, 255) + "...";

                    } else if (subtext.Length > 255) {
                        SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'subtext'");
                        title = title.Substring (0, 255) + "...";
                    }

                    Notification notification = new Notification () {
                        Summary = title,
                        Body    = subtext,
                        Timeout = 5 * 1000,
                        Urgency = Urgency.Low
                    };

                    if (image_path != null)
                        notification.Icon = new Gdk.Pixbuf (image_path);
                    else
                        notification.IconName = "folder-sparkleshare";

                    notification.Closed += delegate (object o, EventArgs args) {
                        if ((args as CloseArgs).Reason == CloseReason.User)
                            Controller.BubbleClicked ();
                    };

                    notification.Show ();

                } catch (Exception e) {
                    SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e);
                }
            };
        }
Esempio n. 19
0
 internal static void DisplayMessage()
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task current = tasks.CurrentTask();
     Notification notify;
     if (current != null)
     {
         notify = new Notification("Tasks", "Are you still working on this task?\n" + current.Summary);
         notify.AddAction("yes", "Yes", HandleDoNothing);
         notify.AddAction("view", "View", HandleEditTask);
         notify.AddAction("finish", "Finish", HandleFinishedTask);
         notify.Timeout = 0;
         notify.Urgency = Urgency.Critical;
         notify.Show();
     }
     else
     {
         SuggestTask();
     }
 }
Esempio n. 20
0
        static LibNotify.Notification ToNotify(string title, string message, string icon)
        {
            LibNotify.Notification notify = new LibNotify.Notification();
            notify.Body    = GLib.Markup.EscapeText(message);
            notify.Summary = title;
            notify.Timeout = ReadableDurationForMessage(title, message);

            if (SupportsCapability(NotificationCapability.scaling) && !icon.Contains("@"))
            {
                notify.IconName = string.IsNullOrEmpty(icon)
                                        ? DefaultIconName
                                        : icon;
            }
            else
            {
                notify.Icon = string.IsNullOrEmpty(icon)
                                        ? DefaultIcon
                                        : DockServices.Drawing.LoadIcon(icon, NoteIconSize);
            }

            return(notify);
        }
Esempio n. 21
0
        public SparkleBubbles()
        {
            Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
                try {
                    Notification notification = new Notification () {
                        Timeout  = 5 * 1000,
                        Urgency  = Urgency.Low
                    };

                    if (image_path != null)
                        notification.Icon = new Gdk.Pixbuf (image_path);
                    else
                        notification.IconName = "folder-sparkleshare";

                    notification.Show ();

                } catch (Exception) {
                    // Ignore exceptions thrown by libnotify,
                    // they're not important enough to crash
                }
            };
        }
Esempio n. 22
0
        public static void NotifyUnreadPosts(int unread, int new_items)
        {
            if(note == null){
                try {
                    note = new Notification();
                    note.IconName = "blam";
                    note.Summary = Catalog.GetString("Feeds refreshed");
                    note.Urgency = Urgency.Normal;
                } catch(Exception e){
                    return;
                }
            }
            /* Same as for the tray icon tooltip */
            /* Total number of unread items */
            string str = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", unread),
                                             unread);
            str += " ";
            /* Number of new (not-skipped-over) entries. Gets appended to previous string */
            str += string.Format(Catalog.GetPluralString("({0} new)", "({0} new)", new_items), new_items);

            note.Body = str;
            note.Show();
        }
Esempio n. 23
0
 protected void OnButtonOkClicked(object sender, System.EventArgs e)
 {
     TaskSettings settings = new TaskSettings();
     string data = interval.Text;
     try
     {
         settings.interval = Int32.Parse(data)*1000*60; //Convert Minutes into milliseconds.
         settings.name = name.Text;
         settings.email = email_address.Text;
         settings.subject = email_subject.Text;
         settings.destination = email_destination.Text;
         settings.smtpServer = smtp_server.Text;
         settings.smtpport = smtp_port.Text;
         settings.password = email_password.Text;
         settings.Save();
         this.Destroy();
     }
     catch (Exception i)
     {
         Notification error = new Notification("Error", i.Message, Stock.Stop);
         error.Show();
     }
 }
Esempio n. 24
0
 public override void DesktopNotify(ActivityFeedItemTemplate template, IActivityFeedItem item, string text)
 {
     // FIXME: This will need to be different on windows/osx...
     QApplication.Invoke(delegate {
         Notification notif = new Notification(text, item.Content);
         foreach (var action in template.Actions) {
             notif.AddAction(action.Name, action.Label, delegate {
                 item.TriggerAction(action.Name);
             });
         }
         notif.Show ();
     });
 }
Esempio n. 25
0
		static void CheckComposite (uint timeout)
		{
			if (checkCompositeTimer > 0) {
				GLib.Source.Remove (checkCompositeTimer);
				checkCompositeTimer = 0;
			}
			
			// compositing is enabled and we are still showing a notify, so close it
			if (Gdk.Screen.Default.IsComposited && compositeNotify != null) {
				compositeNotify.Close ();
				compositeNotify = null;
				return;
			}
			
			checkCompositeTimer = GLib.Timeout.Add (timeout * 1000, delegate {
				checkCompositeTimer = 0;

				// no matter what, close any notify open
				if (compositeNotify != null) {
					compositeNotify.Close ();
					compositeNotify = null;
				}
				
				if (!Gdk.Screen.Default.IsComposited)
					compositeNotify = Log.Notify (Catalog.GetString ("Docky requires compositing to work properly. " +
						"Certain options are disabled and themes/animations will look incorrect. "));
				
				return false;
			});
		}
Esempio n. 26
0
 static void HandleFinishedTask(object sender, ActionArgs e)
 {
     Tasks tasks = new Tasks();
     tasks.Load();
     Task task = tasks.CurrentTask();
     tasks.SetCurrentTaskFinished();
     Notification notify = new Notification();
     notify.Summary = "Task Finished";
     notify.Body = task.Summary;
     notify.Urgency = Urgency.Critical;
     notify.Show();
     SuggestTask();
 }
Esempio n. 27
0
 public static void ShowAppNotification(Notification notification)
 {
     // TODO: Use this API for newer versions of notify-sharp
     //notification.AttachToStatusIcon(
     //		Tasque.Application.Instance.trayIcon);
     notification.Show();
 }
Esempio n. 28
0
 public void Notify(Notification note, Screen screen, int x, int y)
 {
     LibNotify.Notification notify = ToNotify(note);
     notify.SetGeometryHints(screen, x, y);
     notify.Show();
 }
Esempio n. 29
0
        public static void Main(string[] args)
        {
            ThreadState ts = new ThreadState();

              WaitCallback notifyMsg = state =>
              {
            while (ts.Enabled)
            {
              Thread.Sleep(500);

              if (_msgQ.Count > 0)
              {
            NfMessage msg = (NfMessage)_msgQ.Dequeue();
            #if NOTIFY
            Notification nf = new Notification(msg.Summary,
                                               msg.Body,
                                               msg.Icon);
            nf.AddHint("append", "allowed");
            nf.Show();
            #else
            Console.WriteLine("{0}: {1}", msg.Summary, msg.Body);
            #endif
              }
            }

            ts.Notification.Set();
              };

              ThreadPool.QueueUserWorkItem(notifyMsg);

              //using (WebSocket ws = new WebSocket("ws://echo.websocket.org", "echo"))
              //using (WebSocket ws = new WebSocket("wss://echo.websocket.org", "echo"))
              using (WebSocket ws = new WebSocket("ws://localhost:4649"))
              {
            ws.OnOpen += (sender, e) =>
            {
              ws.Send("Hi, all!");
            };

            ws.OnMessage += (sender, e) =>
            {
              if (!String.IsNullOrEmpty(e.Data))
              {
            enNfMessage("[WebSocket] Message", e.Data, "notification-message-im");
              }
            };

            ws.OnError += (sender, e) =>
            {
              enNfMessage("[WebSocket] Error", e.Message, "notification-message-im");
            };

            ws.OnClose += (sender, e) =>
            {
              enNfMessage(
            String.Format("[WebSocket] Close({0}:{1})", (ushort)e.Code, e.Code),
            e.Reason,
            "notification-message-im");
            };

            ws.Connect();

            Thread.Sleep(500);
            Console.WriteLine("\nType \"exit\" to exit.\n");

            string data;
            while (true)
            {
              Thread.Sleep(500);

              Console.Write("> ");
              data = Console.ReadLine();
              if (data == "exit")
              //if (data == "exit" || !ws.IsConnected)
              {
            break;
              }

              ws.Send(data);
            }
              }

              ts.Enabled = false;
              ts.Notification.WaitOne();
        }
Esempio n. 30
0
    protected bool timer_Elapsed()
    {
        var recentPosts = GetRecentPosts();

        try
        {
            if (recentPosts.Count != 0)
            {
                bool alreadyPlayedSound = false;

                foreach (var post in recentPosts)
                {
                    //check if post hasn't already been  notified
                    if (!lastRecentPosts.Any(x => x.pid == post.pid) && IsCategoryEnabled(post.category.cid))
                    {
                        if (cbOnlyNewTopics.Active && !post.isMainPost)
                        {
                            continue;
                        }

                        string decodedTitle   = HttpUtility.HtmlDecode(post.topic.title),
                               decodedContent = HttpUtility.HtmlDecode(RemoveHTML(post.content));

                        if (cbTitleContains.Active || cbBodyContains.Active)
                        {
                            string strToSearch = "";

                            if (cbTitleContains.Active)
                            {
                                strToSearch += decodedTitle;
                            }
                            if (cbBodyContains.Active)
                            {
                                strToSearch += decodedContent;
                            }

                            if (!strToSearch.Contains(textviewContains.Buffer.Text))
                            {
                                continue;
                            }
                        }

                        if (cbIgnoreUsers.Active && ignoredUsers.Contains(post.user.username))
                        {
                            continue;
                        }

                        string linkToPost = "https://forums.gta5-mods.com/post/" + post.pid.ToString();

                        string decodedCategory = HttpUtility.HtmlDecode(post.category.name);

                        string body;
                        if (decodedContent.Length > 100)
                        {
                            body = decodedContent.Substring(0, 97) + "...";
                        }
                        else
                        {
                            body = decodedContent;
                        }

                        TreeIter iter;

                        if (treeStore.IterNChildren() == 50)
                        {
                            //remove oldest item
                            treeStore.IterNthChild(out iter, 49);

                            treeStore.Remove(ref iter);
                        }

                        iter = treeStore.InsertWithValues(0, decodedCategory, decodedTitle, body, linkToPost);

                        tvNotifications.Selection.SelectIter(iter);

                        tvNotifications.ScrollToCell(treeStore.GetPath(iter), columnCategory, true, 0f, 0f);

                        if (!alreadyPlayedSound)
                        {
                            alreadyPlayedSound = true;

                            if (cbPlayNotificationSound.Active)
                            {
                                SystemSounds.Beep.Play();
                                Thread.Sleep(150);
                                SystemSounds.Beep.Play();
                            }
                        }

                        int platform = (int)Environment.OSVersion.Platform;

                        if (platform == 4 || platform == 128) //Unix
                        {
                            var notify = new Notifications.Notification(decodedTitle, body, Gdk.Pixbuf.LoadFromResource("GTA5MFNotifier.Resources.icon.png"));
                            notify.Timeout = 5000;

                            notify.AddAction("click", "View in browser", (object o, ActionArgs args) =>
                            {
                                Process.Start(linkToPost);
                            });

                            notify.Show();
                        }
                        else if (platform != 6) //Windows (6 == MacOS)
                        {
                            var notification = new GTA5MFNotifier.Notification(linkToPost, decodedTitle, body, 10, FormAnimator.AnimationMethod.Slide, FormAnimator.AnimationDirection.Left);
                            notification.Show();
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            lastRecentPosts = recentPosts;
        }

        return(true);
    }
Esempio n. 31
0
        private void CloseWindow(object o, EventArgs args)
        {
            try {
                if (NotifyOnCloseSchema.Get ()) {
                    Gdk.Pixbuf image = IconThemeUtils.LoadIcon (48, Banshee.ServiceStack.Application.IconName);

                    Notification nf = new Notification (
                        Catalog.GetString ("Still Running"),
                        Catalog.GetString ("Banshee was closed to the notification area. " +
                            "Use the <i>Quit</i> option to end your session."),
                        image, notif_area.Widget);
                    nf.Urgency = Urgency.Low;
                    nf.Timeout = 4500;
                    nf.Show ();

                    NotifyOnCloseSchema.Set (false);
                }
            } catch {
            }

            elements_service.PrimaryWindow.SetVisible (false);
        }
Esempio n. 32
0
        void ShowNotification(ChatView chatView, MessageModel msg)
        {
            Notification notification;
            if (!Capabilites.Contains("append") &&
                Notifications.TryGetValue(chatView, out notification)) {
                // no support for append, update the existing notification
                notification.Body = GLib.Markup.EscapeText(
                    msg.ToString()
                );
                return;
            }

            notification = new Notification() {
                Summary = chatView.Name,
                Category = "im.received"
            };
            if (Capabilites.Contains("body")) {
                // notify-osd doesn't like unknown tags when appending
                notification.Body = GLib.Markup.EscapeText(
                    msg.ToString()
                );
            }
            //notification.IconName = "notification-message-im";
            if (Capabilites.Contains("icon-static")) {
                if (chatView is PersonChatView) {
                    notification.Icon = PersonChatIconPixbuf;
                }
                if (chatView is GroupChatView) {
                    notification.Icon = GroupChatIconPixbuf;
                }
            }
            if (Capabilites.Contains("actions")) {
                notification.AddAction("show", _("Show"), delegate {
                    try {
                        MainWindow.PresentWithServerTime();
                        MainWindow.Notebook.CurrentChatView = chatView;
                        notification.Close();
                    } catch (Exception ex) {
            #if LOG4NET
                        Logger.Error("OnChatViewMessageHighlighted() " +
                                     "notification.Show threw exception", ex);
            #endif
                    }
                });
            }
            if (Capabilites.Contains("append")) {
                notification.AddHint("append", String.Empty);
            }
            if (Capabilites.Contains("sound")) {
                // DNS 0.9 only supports sound-file which is a file path
                // http://www.galago-project.org/specs/notification/0.9/x344.html
                // DNS 1.1 supports sound-name which is an id, see:
                // http://people.canonical.com/~agateau/notifications-1.1/spec/ar01s08.html
                // http://0pointer.de/public/sound-naming-spec.html
                // LAMESPEC: We can't tell which of those are actually
                // supported by this version as hint are totally optional :/
                // HACK: always pass both hints when possible
                notification.AddHint("sound-name", "message-new-instant");
                if (SoundFile != null) {
                    notification.AddHint("sound-file", SoundFile);
                }
            }
            notification.Closed += delegate {
                try {
            #if LOG4NET
                    Logger.Debug("OnChatViewMessageHighlighted(): received " +
                                 "notification.Closed signal for: " +
                                 chatView.Name);
            #endif
                    Notifications.Remove(chatView);
                } catch (Exception ex) {
            #if LOG4NET
                    Logger.Error("OnChatViewMessageHighlighted(): " +
                                 "Exception in notification.Closed handler",
                                 ex);
            #endif
                }
            };
            notification.Show();

            if (!Notifications.ContainsKey(chatView)) {
                Notifications.Add(chatView, notification);
            }
        }
Esempio n. 33
0
        private void configure()
        {
            #if DEBUG
              _ws.Log.Level = LogLevel.TRACE;
              #endif
              _ws.OnOpen += (sender, e) =>
              {
            var msg = createTextMessage("connection", String.Empty);
            _ws.Send(msg);
              };

              _ws.OnMessage += (sender, e) =>
              {
            switch (e.Type)
            {
              case Opcode.TEXT:
            var msg = parseTextMessage(e.Data);
            _msgQ.Enqueue(msg);
            break;
              case Opcode.BINARY:
            var audioMsg = parseAudioMessage(e.RawData);
            if (audioMsg.user_id == _user_id) goto default;
            if (_audioBox.ContainsKey(audioMsg.user_id))
            {
              _audioBox[audioMsg.user_id].Enqueue(audioMsg.buffer_array);
            }
            else
            {
              var q = Queue.Synchronized(new Queue());
              q.Enqueue(audioMsg.buffer_array);
              _audioBox.Add(audioMsg.user_id, q);
            }
            break;
              default:
            break;
            }
              };

              _ws.OnError += (sender, e) =>
              {
            enNfMessage("[AudioStreamer] error", "WS: Error: " + e.Message, "notification-message-im");
              };

              _ws.OnClose += (sender, e) =>
              {
            enNfMessage
            (
              "[AudioStreamer] disconnect",
              String.Format("WS: Close({0}: {1})", e.Code, e.Reason),
              "notification-message-im"
            );
              };

              //_ws.Compression = CompressionMethod.DEFLATE;

              _notifyMsgState = new ThreadState();
              _notifyMsg = (state) =>
              {
            while (_notifyMsgState.Enabled || _msgQ.Count > 0)
            {
              Thread.Sleep(500);

              if (_msgQ.Count > 0)
              {
            NfMessage msg = (NfMessage)_msgQ.Dequeue();
            #if NOTIFY
            Notification nf = new Notification(msg.Summary,
                                               msg.Body,
                                               msg.Icon);
            nf.AddHint("append", "allowed");
            nf.Show();
            #else
            Console.WriteLine("{0}: {1}", msg.Summary, msg.Body);
            #endif
              }
            }

            _notifyMsgState.Notification.Set();
              };

              _sendHeartbeat = (state) =>
              {
            var msg = createTextMessage("heartbeat", String.Empty);
            _ws.Send(msg);
              };
        }
Esempio n. 34
0
        private void ShowTrackNotification ()
        {
            // This has to happen before the next if, otherwise the last_* members aren't set correctly.
            if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle
                && notify_last_artist == current_track.DisplayArtistName)) {
                return;
            }

            notify_last_title = current_track.DisplayTrackTitle;
            notify_last_artist = current_track.DisplayArtistName;

            if (!show_notifications) {
                return;
            }

            foreach (var window in elements_service.ContentWindows) {
                if (window.HasToplevelFocus) {
                    return;
                }
            }

            bool is_notification_daemon = false;
            try {
                var name = Notifications.Global.ServerInformation.Name;
                is_notification_daemon = name == "notification-daemon" || name == "Notification Daemon";
            } catch {
                // This will be reached if no notification daemon is running
                return;
            }

            string message = GetByFrom (
                current_track.ArtistName, current_track.DisplayArtistName,
                current_track.AlbumTitle, current_track.DisplayAlbumTitle);

            string image = null;

            image = is_notification_daemon
                ? CoverArtSpec.GetPathForSize (current_track.ArtworkId, icon_size)
                : CoverArtSpec.GetPath (current_track.ArtworkId);

            if (!File.Exists (new SafeUri(image))) {
                if (artwork_manager_service != null) {
                    // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion
                    Gdk.Pixbuf tmp_pixbuf = is_notification_daemon
                        ? artwork_manager_service.LookupScalePixbuf (current_track.ArtworkId, icon_size)
                        : artwork_manager_service.LookupPixbuf (current_track.ArtworkId);

                    if (tmp_pixbuf == null) {
                        image = "audio-x-generic";
                    } else {
                        tmp_pixbuf.Dispose ();
                    }
                }
            }

            try {
                if (current_nf == null) {
                    current_nf = new Notification (current_track.DisplayTrackTitle,
                        message, image, notif_area.Widget);
                } else {
                    current_nf.Summary = current_track.DisplayTrackTitle;
                    current_nf.Body = message;
                    current_nf.IconName = image;
                    current_nf.AttachToWidget (notif_area.Widget);
                }
                current_nf.Urgency = Urgency.Low;
                current_nf.Timeout = 4500;
                if (!current_track.IsLive && ActionsSupported && interface_action_service.PlaybackActions["NextAction"].Sensitive) {
                    current_nf.AddAction ("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped);
                }
                current_nf.Show ();
            } catch (Exception e) {
                Hyena.Log.Warning (Catalog.GetString ("Cannot show notification"), e.Message, false);
            }
        }
Esempio n. 35
0
        private void ShowTrackNotification()
        {
            // This has to happen before the next if, otherwise the last_* members aren't set correctly.
            if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle
                && notify_last_artist == current_track.DisplayArtistName)) {
                return;
            }

            notify_last_title = current_track.DisplayTrackTitle;
            notify_last_artist = current_track.DisplayArtistName;

            if (!show_notifications) {
                return;
            }

            // If we have persistent notifications, we show a notification even if the main window has focus
            // so that the information displayed (track title, etc.) gets updated.
            if (!PersistenceSupported) {
                foreach (var window in elements_service.ContentWindows) {
                    if (window.HasToplevelFocus) {
                        return;
                    }
                }
            }

            string message = GetByFrom (
                current_track.ArtistName, current_track.DisplayArtistName,
                current_track.AlbumTitle, current_track.DisplayAlbumTitle);

            string image = null;

            image = CoverArtSpec.GetPath (current_track.ArtworkId);

            if (!File.Exists (new SafeUri(image))) {
                if (artwork_manager_service != null) {
                    // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion
                    Gdk.Pixbuf tmp_pixbuf = artwork_manager_service.LookupPixbuf (current_track.ArtworkId);

                    if (tmp_pixbuf == null) {
                        // TODO: image should be set to "audio-x-generic", but icon names are not supported by the
                        // notification daemon in GNOME Shell. See https://bugzilla.gnome.org/show_bug.cgi?id=665957
                        image = null;
                    } else {
                        tmp_pixbuf.Dispose ();
                    }
                }
            }

            try {
                if (current_nf == null) {
                    current_nf = new Notification (current_track.DisplayTrackTitle,
                        message, Banshee.ServiceStack.Application.IconName);
                } else {
                    current_nf.Summary = current_track.DisplayTrackTitle;
                    current_nf.Body = message;
                    current_nf.IconName = Banshee.ServiceStack.Application.IconName;
                    if (notif_area != null && notif_area.Widget != null) {
                        current_nf.AttachToWidget (notif_area.Widget);
                    }
                }
                current_nf.Urgency = Urgency.Low;
                current_nf.Timeout = 4500;

                if (image == null) {
                    current_nf.RemoveHint ("image-path");
                } else {
                    current_nf.AddHint ("image-path", image);
                }

                if (ServiceManager.PlayerEngine.IsPlaying ()) {
                    current_nf.Category = "x-gnome.music";
                }

                if (PersistenceSupported) {
                    current_nf.AddHint ("resident", true);
                }

                current_nf.Show ();
            } catch (Exception e) {
                Log.Error (Catalog.GetString ("Cannot show notification"), e);
            }
        }
Esempio n. 36
0
        private void ShowTrackNotification()
        {
            // This has to happen before the next if, otherwise the last_* members aren't set correctly.
            if (current_track == null || (notify_last_title == current_track.DisplayTrackTitle
                && notify_last_artist == current_track.DisplayArtistName)) {
                return;
            }

            notify_last_title = current_track.DisplayTrackTitle;
            notify_last_artist = current_track.DisplayArtistName;

            if (!show_notifications) {
                return;
            }

            // If we have persistent notifications, we show a notification even if the main window has focus
            // so that the information displayed (track title, etc.) gets updated.
            if (!PersistenceSupported) {
                foreach (var window in elements_service.ContentWindows) {
                    if (window.HasToplevelFocus) {
                        return;
                    }
                }
            }

            string message = GetByFrom (
                current_track.ArtistName, current_track.DisplayArtistName,
                current_track.AlbumTitle, current_track.DisplayAlbumTitle);

            string image = null;

            image = CoverArtSpec.GetPath (current_track.ArtworkId);

            if (!File.Exists (new SafeUri(image))) {
                if (artwork_manager_service != null) {
                    // artwork does not exist, try looking up the pixbuf to trigger scaling or conversion
                    Gdk.Pixbuf tmp_pixbuf = artwork_manager_service.LookupPixbuf (current_track.ArtworkId);

                    if (tmp_pixbuf == null) {
                        // TODO: image should be set to "audio-x-generic", but icon names are not supported by the
                        // notification daemon in GNOME Shell. See https://bugzilla.gnome.org/show_bug.cgi?id=665957
                        image = null;
                    } else {
                        tmp_pixbuf.Dispose ();
                    }
                }
            }

            try {
                if (current_nf == null) {
                    current_nf = new Notification (current_track.DisplayTrackTitle,
                        message, Banshee.ServiceStack.Application.IconName);
                } else {
                    current_nf.Summary = current_track.DisplayTrackTitle;
                    current_nf.Body = message;
                    current_nf.IconName = Banshee.ServiceStack.Application.IconName;
                    if (notif_area != null && notif_area.Widget != null) {
                        current_nf.AttachToWidget (notif_area.Widget);
                    }
                }
                current_nf.Urgency = Urgency.Low;
                current_nf.Timeout = 4500;

                if (!current_track.IsLive && ActionsSupported && interface_action_service.PlaybackActions["NextAction"].Sensitive) {
                    if (ActionIconsSupported) {
                        current_nf.AddHint ("action-icons", true);

                        // We need to use an icon name as the action id, so that the notification uses that icon
                        current_nf.AddAction ("media-skip-backward",
                            Catalog.GetString("Previous"), OnPreviousTrack);

                        bool is_playing = ServiceManager.PlayerEngine.IsPlaying ();
                        current_nf.AddAction (is_playing ? "media-playback-pause" : "media-playback-start",
                            interface_action_service.PlaybackActions["PlayPauseAction"].Label, OnPlayPause);
                    }

                    current_nf.AddAction ("media-skip-forward",
                        Catalog.GetString("Skip this item"), OnNextTrack);
                }

                if (image == null) {
                    current_nf.RemoveHint ("image-path");
                } else {
                    current_nf.AddHint ("image-path", image);
                }

                if (PersistenceSupported) {
                    current_nf.AddHint ("resident", true);
                }

                current_nf.Show ();
            } catch (Exception e) {
                Hyena.Log.Exception (Catalog.GetString ("Cannot show notification"), e);
            }
        }