Example #1
0
        private void EnableInterceptor()
        {
            // Make sure we're unregistered....
            if (!MessageInterceptor.IsApplicationLauncherEnabled(AppRegisterName))
            {
                // instance the Interceptor
                smsInterceptor = new MessageInterceptor();

                try
                {
                    // register the interceptor.
                    string smsEngine = Assembly.GetExecutingAssembly().GetName().CodeBase.Replace("SmsToEmail.exe", "SmsEngine.exe");
                    smsInterceptor.MessageCondition.Property        = MessageProperty.MessageClass;
                    smsInterceptor.InterceptionAction               = InterceptionAction.Notify;
                    smsInterceptor.MessageCondition.CaseSensitive   = false;
                    smsInterceptor.MessageCondition.ComparisonType  = MessagePropertyComparisonType.Contains;
                    smsInterceptor.MessageCondition.ComparisonValue = "SMS";
                    smsInterceptor.EnableApplicationLauncher(AppRegisterName,
                                                             smsEngine,
                                                             "1");
                }
                catch
                {
                    MessageBox.Show("Unable to register MessageInterceptor, please contact Carbon Software Tech-Support");
                }
                finally
                {
                    smsInterceptor.Dispose();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Call this method to initialize message interceptor.
        /// </summary>
        /// <param name="applicationID">a unique id in the registry for identifying the message filter rule</param>
        public void initializeMsgInterceptor(String applicationID)
        {
            appId = applicationID;
            receiveControlPrefix = "SMS+" + receivingProjectCode + receivingProgramCode;
            // If the message interceptor is already enabled then
            // retrieve its current settings. Otherwise configure
            // a new instance

            if (MessageInterceptor.IsApplicationLauncherEnabled(appId))
            {
                // clean up the key
                RegistryKey rk = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Inbox\\Rules", true);
                rk.DeleteSubKeyTree(appId);
                rk.Close();
            }


            // We want to intercept messages that begin with "CKF:" within the
            // message body and delete these messages before they reach the
            // SMS inbox.
            smsInterceptor = new MessageInterceptor(InterceptionAction.NotifyAndDelete, false);
            smsInterceptor.MessageCondition = new MessageCondition(MessageProperty.Body,
                                                                   MessagePropertyComparisonType.StartsWith, receiveControlPrefix);

            // Enable the message interceptor, launch application when a certain condition met.
            smsInterceptor.EnableApplicationLauncher(appId);
            smsInterceptor.MessageReceived += SmsInterceptor_MessageReceived;
        }
Example #3
0
        private void DisableInterceptor()
        {
            // Make sure we're registered....
            if (MessageInterceptor.IsApplicationLauncherEnabled(AppRegisterName))
            {
                // instance the Interceptor
                smsInterceptor = new MessageInterceptor(AppRegisterName);

                try
                {
                    // unregister the interceptor.
                    smsInterceptor.DisableApplicationLauncher();
                }
                catch { }
                finally
                {
                    smsInterceptor.Dispose();
                }
            }
        }
Example #4
0
        private void ApplyConfig()
        {
            if (dbManager.CanPrompt())
            {
                this.ChkBoxPrompt.Checked = true;
            }
            else
            {
                this.ChkBoxPrompt.Checked = false;
            }

            if (MessageInterceptor.IsApplicationLauncherEnabled(AppRegisterName))
            {
                this.ChkBoxEnable.Checked = true;
            }
            else
            {
                this.ChkBoxEnable.Checked = false;
            }

            if (dbManager.CanSynchronize())
            {
                this.ChkBoxSync.Checked = true;
            }
            else
            {
                this.ChkBoxSync.Checked = false;
            }

            RegistryKey key = Registry.LocalMachine.OpenSubKey("Carbon Software Ltd");

            if (key != null)
            {
                string result = Convert.ToString(key.GetValue("serial"));

                if ((result.Trim().Length > 0) && (this.serials.Contains(result.Trim())))
                {
                    this.tpAccounts.Show();
                    this.tpRecipients.Show();
                    this.tpOptions.Show();

                    try
                    {
                        this.tabControl.TabPages.RemoveAt(3);
                    }
                    catch
                    {
                        this.tpRegister.Hide();
                    }
                    finally
                    {
                        this.tabControl.SelectedIndex = 0;
                    }
                }
                else
                {
                    this.tpAccounts.Hide();
                    this.tpRecipients.Hide();
                    this.tpOptions.Hide();

                    this.tabControl.SelectedIndex = 3;
                }
            }
            else
            {
                this.tpAccounts.Hide();
                this.tpRecipients.Hide();
                this.tpOptions.Hide();
            }
        }
Example #5
0
        public Engine(string[] args)
        {
            // If the interceptor is enabled
            if (MessageInterceptor.IsApplicationLauncherEnabled(AppRegisterName))
            {
                // We started this app via an SMS {1}
                if (args.Length > 0)
                {
                    // An SMS started the Engine...
                    if (args[0].Equals("1"))
                    {
                        InitializeComponent();

                        dbManager = new DatabaseManager(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase));

                        // we must have both accounts and recipients to proceed!
                        if ((dbManager.ACCOUNTS.Rows.Count > 0) && (dbManager.RECIPIENTS.Rows.Count > 0))
                        {
                            this.session    = new OutlookSession();
                            this.collection = session.EmailAccounts;

                            // Set the recipient collection
                            this.recipientCollection = dbManager.RECIPIENTS.Rows;

                            if (collection.Count > 0)
                            {
                                // Set the email account
                                this.emailAccount = collection[Convert.ToString(dbManager.ACCOUNTS.Rows[0]["ADDRESS"])];

                                if (this.emailAccount != null)
                                {
                                    // Create the Interceptor
                                    smsInterceptor = new MessageInterceptor(AppRegisterName, true);
                                    smsInterceptor.MessageReceived += new MessageInterceptorEventHandler(smsInterceptor_MessageReceived);
                                }
                                else
                                {
                                    this.Close();
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }