From b5ef0baf3985f385e09c92370b4d1a8deb548537 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 18 Nov 2010 00:51:34 +0000 Subject: [PATCH] [controller] SetProcessName belongs to SS main class --- SparkleShare/SparkleController.cs | 31 ---------------------------- SparkleShare/SparkleIntro.cs | 4 ++-- SparkleShare/SparkleShare.cs | 34 ++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 998897bf..31672846 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -15,14 +15,11 @@ // along with this program. If not, see . using Mono.Unix; -using Mono.Unix.Native; using SparkleLib; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Runtime.InteropServices; -using System.Text; using System.Threading; namespace SparkleShare { @@ -63,8 +60,6 @@ namespace SparkleShare { public SparkleController () { - - SetProcessName ("sparkleshare"); InstallLauncher (); EnableSystemAutostart (); @@ -621,32 +616,6 @@ namespace SparkleShare { } - - // Sets the unix process name to 'sparkleshare' instead of 'mono' - private void SetProcessName (string name) - { - - try { - - if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) { - - throw new ApplicationException ("Error setting process name: " + - Mono.Unix.Native.Stdlib.GetLastError ()); - - } - - } catch (EntryPointNotFoundException) { - - Console.WriteLine ("SetProcessName: Entry point not found"); - - } - - } - - - // Strange magic needed by SetProcessName - [DllImport ("libc")] - private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5); // Quits the program public void Quit () diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index 823f8318..a0a346b8 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -769,10 +769,10 @@ namespace SparkleShare { // Checks to see if an email address is valid - private bool IsValidEmail(string email) + private bool IsValidEmail (string email) { - Regex regex = new Regex(@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase); + Regex regex = new Regex (@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", RegexOptions.IgnoreCase); return regex.IsMatch (email); } diff --git a/SparkleShare/SparkleShare.cs b/SparkleShare/SparkleShare.cs index f7a9ce8b..71e2014d 100644 --- a/SparkleShare/SparkleShare.cs +++ b/SparkleShare/SparkleShare.cs @@ -16,12 +16,15 @@ using Gtk; using Mono.Unix; +using Mono.Unix.Native; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; using SparkleLib; using SparkleLib.Options; +using System.Text; namespace SparkleShare { @@ -41,7 +44,9 @@ namespace SparkleShare { public static void Main (string [] args) { - + + SetProcessName ("sparkleshare"); + // Use translations Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR); @@ -138,6 +143,33 @@ namespace SparkleShare { } + + // Sets the unix process name to 'sparkleshare' instead of 'mono' + private static void SetProcessName (string name) + { + + try { + + if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) { + + throw new ApplicationException ("Error setting process name: " + + Mono.Unix.Native.Stdlib.GetLastError ()); + + } + + } catch (EntryPointNotFoundException) { + + Console.WriteLine ("SetProcessName: Entry point not found"); + + } + + } + + + // Strange magic needed by SetProcessName + [DllImport ("libc")] + private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5); + } }