Example #1
0
        private void Next()
        {
            if (pnlConfig.Visible)
            {
                MainForm.IPLISTED = tbl1.Enabled;
                MainForm.IPRTSP   = chkRTSP.Checked;
                MainForm.IPHTTP   = chkHTTP.Checked;
                if (MainForm.IPLISTED)
                {
                    if (!_hashdata.Contains(txtFindModel.Text.ToUpper()))
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseMake"));
                        return;
                    }
                }
                else
                {
                    if (!MainForm.IPRTSP && !MainForm.IPHTTP)
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseOption"));
                        return;
                    }
                }
                ShowPanel(pnlLogin);
                return;
            }
            if (pnlLogin.Visible)
            {
                ShowPanel(pnlFindNetwork);
                return;
            }
            if (pnlFindNetwork.Visible)
            {
                string addr = txtIPAddress.Text.Trim();
                if (string.IsNullOrEmpty(addr))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPAddress"));
                    return;
                }
                Uri nUrl = null;
                if (!Uri.TryCreate("http://" + addr, UriKind.Absolute, out nUrl))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPDNSOnly"));
                    return;
                }

                AddConnections();
                return;
            }
            if (pnlConnect.Visible)
            {
                if (MainForm.IPLISTED && txtFindModel.Text == "")
                {
                    ShowPanel(pnlConfig);
                    return;
                }

                string make  = txtMake.Text;
                string model = txtModel.Text;
                FinalUrl = "";

                if (MainForm.IPLISTED)
                {
                    var mm = txtFindModel.Text.Split(':');

                    make  = mm[0].Trim();
                    model = "";
                    if (mm.Length > 1)
                    {
                        model = mm[1].Trim().ToUpper();
                    }
                }


                ManufacturersManufacturerUrl s = null;
                for (int j = 0; j < pnlOptions.Controls.Count; j++)
                {
                    if (pnlOptions.Controls[j] is RadioButton)
                    {
                        if (((RadioButton)pnlOptions.Controls[j]).Checked)
                        {
                            var o = (pnlOptions.Controls[j]).Tag;
                            if (o is ManufacturersManufacturerUrl)
                            {
                                s = o as ManufacturersManufacturerUrl;

                                FinalUrl = GetAddr(s).ToString();

                                string source = s.Source;
                                if (source == "VLC" && !_vlc)
                                {
                                    source = "FFMPEG";
                                }

                                switch (source)
                                {
                                case "JPEG":
                                    VideoSourceType = 0;
                                    break;

                                case "MJPEG":
                                    VideoSourceType = 1;
                                    break;

                                case "FFMPEG":
                                    VideoSourceType = 2;
                                    break;

                                case "VLC":
                                    VideoSourceType = 5;
                                    break;
                                }
                                AudioSourceType = -1;
                                if (!string.IsNullOrEmpty(s.AudioSource))
                                {
                                    switch (s.AudioSource.ToUpper())
                                    {
                                    case "FFMPEG":
                                        AudioSourceType = 3;
                                        break;

                                    case "VLC":
                                        AudioSourceType = 2;
                                        if (!_vlc)
                                        {
                                            AudioSourceType = 3;
                                        }
                                        break;

                                    case "WAVSTREAM":
                                        AudioSourceType = 6;
                                        break;
                                    }
                                    AudioUrl = GetAddr(s, true).ToString();
                                }

                                Ptzid = -1;

                                if (!s.@fixed)
                                {
                                    string modellc = model.ToLower();
                                    string n       = make.ToLower();
                                    bool   quit    = false;
                                    foreach (var ptz in MainForm.PTZs)
                                    {
                                        int k = 0;
                                        foreach (var m in ptz.Makes)
                                        {
                                            if (m.Name.ToLower() == n)
                                            {
                                                Ptzid      = ptz.id;
                                                Ptzentryid = k;
                                                string mdl = m.Model.ToLower();
                                                if (mdl == modellc || s.version.ToLower() == mdl)
                                                {
                                                    Ptzid      = ptz.id;
                                                    Ptzentryid = j;
                                                    quit       = true;
                                                    break;
                                                }
                                            }
                                            k++;
                                        }
                                        if (quit)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (o is ConnectionOption)
                                {
                                    //onvif
                                    var co = o as ConnectionOption;
                                    VideoSourceType = 9;
                                    FinalUrl        = co.URL;
                                }
                            }
                            break;
                        }
                    }
                }

                if (string.IsNullOrEmpty(FinalUrl))
                {
                    MessageBox.Show(this, LocRm.GetString("SelectURL"));
                    return;
                }


                MainForm.IPUN      = txtUsername.Text;
                MainForm.IPPASS    = txtPassword.Text;
                MainForm.IPTYPE    = make;
                MainForm.IPMODEL   = model;
                MainForm.IPADDR    = txtIPAddress.Text;
                MainForm.IPPORTS   = txtPorts.Text;
                MainForm.IPPORT    = (int)numPort.Value;
                MainForm.IPCHANNEL = txtChannel.Text.Trim();


                LastConfig.PromptSave = !MainForm.IPLISTED && MainForm.IPMODEL.Trim() != "";

                LastConfig.Iptype  = MainForm.IPTYPE;
                LastConfig.Ipmodel = MainForm.IPMODEL;
                if (s != null)
                {
                    AudioModel         = s.AudioModel;
                    LastConfig.Prefix  = s.prefix;
                    LastConfig.Source  = s.Source;
                    LastConfig.URL     = s.url;
                    LastConfig.Cookies = s.cookies;
                    LastConfig.Flags   = s.flags;

                    tokenPath = s.tokenPath;
                    tokenPost = s.tokenPost;
                    tokenPort = s.tokenPort;


                    if (!string.IsNullOrEmpty(s.port))
                    {
                        LastConfig.Port = Convert.ToInt32(s.port);
                    }
                }
                if (_dt != null)
                {
                    MainForm.IPTABLE = _dt.Copy();
                }
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Example #2
0
 private void RenderResources()
 {
     openFolderToolStripMenuItem.Text = LocRm.GetString("OpenLocalFolder");
     saveAsToolStripMenuItem.Text     = LocRm.GetString("SaveAs");
 }
Example #3
0
        private bool Save()
        {
            if (!CheckStep1())
            {
                return(false);
            }

            string err = "";

            int nosoundinterval;

            if (!int.TryParse(txtNoSound.Text, out nosoundinterval))
            {
                err += LocRm.GetString("Validate_Microphone_NoSound") + Environment.NewLine;
            }
            int soundinterval;

            if (!int.TryParse(txtSound.Text, out soundinterval))
            {
                err += LocRm.GetString("Validate_Microphone_Sound") + Environment.NewLine;
            }


            if (txtBuffer.Text.Length < 1 || txtInactiveRecord.Text.Length < 1 ||
                txtMaxRecordTime.Text.Length < 1)
            {
                err += LocRm.GetString("Validate_Camera_RecordingSettings") + Environment.NewLine;
            }

            if (err != "")
            {
                MessageBox.Show(err, LocRm.GetString("Error"));
                return(false);
            }


            VolumeLevel.Micobject.settings.buffer         = Convert.ToInt32(txtBuffer.Value);
            VolumeLevel.Micobject.recorder.inactiverecord = Convert.ToInt32(txtInactiveRecord.Value);
            VolumeLevel.Micobject.recorder.maxrecordtime  = Convert.ToInt32(txtMaxRecordTime.Value);

            VolumeLevel.Micobject.name = txtMicrophoneName.Text.Trim();

            VolumeLevel.Micobject.alerts.active = chkSound.Checked;

            VolumeLevel.Micobject.alerts.mode = "sound";
            if (rdoNoMovement.Checked)
            {
                VolumeLevel.Micobject.alerts.mode = "nosound";
            }
            VolumeLevel.Micobject.detector.nosoundinterval = nosoundinterval;
            VolumeLevel.Micobject.detector.soundinterval   = soundinterval;

            VolumeLevel.Micobject.schedule.active = chkSchedule.Checked;
            VolumeLevel.Micobject.width           = VolumeLevel.Width;
            VolumeLevel.Micobject.height          = VolumeLevel.Height;

            VolumeLevel.Micobject.settings.active         = chkActive.Checked;
            VolumeLevel.Micobject.detector.recordondetect = rdoRecordDetect.Checked;
            VolumeLevel.Micobject.detector.recordonalert  = rdoRecordAlert.Checked;
            VolumeLevel.Micobject.recorder.minrecordtime  = (int)numMinRecord.Value;

            VolumeLevel.Micobject.settings.accessgroups = txtAccessGroups.Text;
            VolumeLevel.Micobject.settings.messaging    = chkMessaging.Checked;


            if (txtDirectory.Text.Trim() == "")
            {
                txtDirectory.Text = MainForm.RandomString(5);
            }

            var md     = (ListItem)ddlMediaDirectory.SelectedItem;
            var newind = Convert.ToInt32(md.Value);

            string olddir = Helper.GetMediaDirectory(1, VolumeLevel.Micobject.id) + "video\\" + VolumeLevel.Micobject.directory + "\\";

            bool needsFileRefresh = (VolumeLevel.Micobject.directory != txtDirectory.Text || VolumeLevel.Micobject.settings.directoryIndex != newind);

            int tempidx = VolumeLevel.Micobject.settings.directoryIndex;

            VolumeLevel.Micobject.settings.directoryIndex = newind;

            string newdir = Helper.GetMediaDirectory(1, VolumeLevel.Micobject.id) + "video\\" + txtDirectory.Text + "\\";

            if (IsNew)
            {
                try
                {
                    if (!Directory.Exists(newdir))
                    {
                        Directory.CreateDirectory(newdir);
                    }
                    else
                    {
                        switch (
                            MessageBox.Show(this,
                                            LocRm.GetString("Validate_Directory_Exists"),
                                            LocRm.GetString("Confirm"), MessageBoxButtons.YesNoCancel))
                        {
                        case DialogResult.Yes:
                            Directory.Delete(newdir, true);
                            Directory.CreateDirectory(newdir);
                            break;

                        case DialogResult.Cancel:
                            VolumeLevel.Micobject.settings.directoryIndex = tempidx;
                            return(false);

                        case DialogResult.No:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, LocRm.GetString("Validate_Directory_String") + Environment.NewLine + ex.Message);
                    VolumeLevel.Micobject.settings.directoryIndex = tempidx;
                    return(false);
                }
            }
            else
            {
                if (newdir != olddir)
                {
                    try
                    {
                        if (!Directory.Exists(newdir))
                        {
                            if (Directory.Exists(olddir))
                            {
                                if (MessageBox.Show(this, "Copy Files?", LocRm.GetString("Confirm"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    Helper.CopyFolder(olddir, newdir);
                                }
                            }
                            else
                            {
                                Directory.CreateDirectory(newdir);
                            }
                        }
                        else
                        {
                            switch (
                                MessageBox.Show(this,
                                                LocRm.GetString("Validate_Directory_Exists"),
                                                LocRm.GetString("Confirm"), MessageBoxButtons.YesNoCancel))
                            {
                            case DialogResult.Yes:
                                if (Directory.Exists(olddir))
                                {
                                    if (MessageBox.Show(this, "Copy Files?", LocRm.GetString("Confirm"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                                    {
                                        Helper.CopyFolder(olddir, newdir);
                                    }
                                }
                                else
                                {
                                    Directory.Delete(newdir, true);
                                    Directory.CreateDirectory(newdir);
                                }
                                break;

                            case DialogResult.Cancel:
                                VolumeLevel.Micobject.settings.directoryIndex = tempidx;
                                return(false);

                            case DialogResult.No:
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, LocRm.GetString("Validate_Directory_String") + Environment.NewLine + ex.Message);
                        VolumeLevel.Micobject.settings.directoryIndex = tempidx;
                        return(false);
                    }
                }
            }


            VolumeLevel.Micobject.directory        = txtDirectory.Text;
            VolumeLevel.Micobject.recorder.trigger = ((ListItem)ddlTriggerRecording.SelectedItem).Value;

            SetStorageManagement();

            MainForm.NeedsSync = true;

            if (needsFileRefresh)
            {
                VolumeLevel.GenerateFileList();
                MainForm.NeedsMediaRebuild = true;
                MainForm.NeedsMediaRefresh = Helper.Now;
            }
            return(true);
        }
Example #4
0
        private void MicrophoneSourceLoad(object sender, EventArgs e)
        {
            tableLayoutPanel2.Enabled = VlcHelper.VlcInstalled;
            linkLabel3.Visible        = lblInstallVLC.Visible = !tableLayoutPanel2.Enabled;
            cmbVLCURL.Text            = MainForm.Conf.VLCURL;
            cmbVLCURL.Items.AddRange(ObjectList(MainForm.Conf.RecentVLCList));
            cmbFFMPEGURL.Items.AddRange(ObjectList(MainForm.Conf.RecentVLCList));
            ddlSampleRate.Items.AddRange(SampleRates);
            try
            {
                int selind = -1;

                for (int n = 0; n < WaveIn.DeviceCount; n++)
                {
                    ddlDevice.Items.Add(WaveIn.GetCapabilities(n).ProductName);
                    if (WaveIn.GetCapabilities(n).ProductName == Mic.settings.sourcename)
                    {
                        selind = n;
                    }
                }


                ddlDevice.Enabled = true;

                if (selind > -1)
                {
                    ddlDevice.SelectedIndex = selind;
                }
                else
                {
                    if (ddlDevice.Items.Count == 0)
                    {
                        ddlDevice.Items.Add(_noDevices);
                        ddlDevice.Enabled = false;
                    }
                    else
                    {
                        ddlDevice.SelectedIndex = 0;
                    }
                }
            }
            catch (ApplicationException ex)
            {
                MainForm.LogExceptionToFile(ex);
                ddlDevice.Items.Add(_noDevices);
                ddlDevice.Enabled = false;
            }
            ddlSampleRate.SelectedIndex = 0;
            foreach (var mic in MainForm.Microphones)
            {
                if (mic.id != Mic.id && mic.settings.typeindex != 5) //dont allow a clone of a clone as the events get too complicated (and also it's pointless)
                {
                    ddlCloneMicrophone.Items.Add(new MainForm.ListItem2(mic.name, mic.id));
                }
            }

            SetSourceIndex(Mic.settings.typeindex);

            switch (Mic.settings.typeindex)
            {
            case 0:
                if (ddlDevice.Items.Count > 0)
                {
                    tcAudioSource.SelectedIndex = 0;
                    int j = 0;
                    foreach (int s in ddlSampleRate.Items)
                    {
                        if (s == Mic.settings.samples)
                        {
                            ddlSampleRate.SelectedIndex = j;
                        }
                        j++;
                    }
                }
                break;

            case 1:
                txtNetwork.Text = Mic.settings.sourcename;
                break;

            case 2:
                cmbVLCURL.Text = Mic.settings.sourcename;
                break;

            case 3:
                cmbFFMPEGURL.Text = Mic.settings.sourcename;
                break;

            case 4:
                int i;
                Int32.TryParse(Mic.settings.sourcename, out i);
                var c = MainForm.Cameras.SingleOrDefault(p => p.id == i);
                lblCamera.Text = c == null?LocRm.GetString("Removed") : c.name;

                break;

            case 5:
                int id;
                if (Int32.TryParse(Mic.settings.sourcename, out id))
                {
                    foreach (MainForm.ListItem2 li in ddlCloneMicrophone.Items)
                    {
                        if (li.Value == id)
                        {
                            ddlCloneMicrophone.SelectedItem = li;
                            break;
                        }
                    }
                }
                break;
            }


            txtVLCArgs.Text = Mic.settings.vlcargs.Replace("\r\n", "\n").Replace("\n\n", "\n").Replace("\n", Environment.NewLine);

            numAnalyseDuration.Value = Mic.settings.analyzeduration;
        }
Example #5
0
        private void PortScannerManager(string host)
        {
            var ports = new List <int>();

            foreach (string s in txtPorts.Text.Split(','))
            {
                int p;
                if (int.TryParse(s, out p))
                {
                    if (p < 65535 && p > 0)
                    {
                        ports.Add(p);
                    }
                }
            }
            UISync.Execute(() => pbScanner.Value = 0);

            var manualEvents = new ManualResetEvent[MaxThreads];
            int j;

            for (int k = 0; k < MaxThreads; k++)
            {
                manualEvents[k] = new ManualResetEvent(true);
            }

            var ipranges = new List <string>();

            if (host == LocRm.GetString("AllAdaptors"))
            {
                ipranges.AddRange(from string s in ddlHost.Items where s != LocRm.GetString("AllAdaptors") select s);
            }
            else
            {
                ipranges.Add(host);
            }

            UISync.Execute(() => pbScanner.Maximum = ipranges.Count * 254);
            Logger.LogMessage("Scanning LAN");
            j = 0;
            foreach (string IP in DnsEntries)
            {
                string ip      = IP;
                int    k       = j;
                var    scanner = new Thread(p => PortScanner(ports, ip, manualEvents[k]));
                scanner.Start();

                j = WaitHandle.WaitAny(manualEvents);
                UISync.Execute(() => pbScanner.PerformStep());
                if (_exiting)
                {
                    break;
                }
            }

            if (!_exiting)
            {
                j = 0;
                foreach (string shost in ipranges)
                {
                    for (int i = 0; i < 255; i++)
                    {
                        string ip = shost.Replace("x", i.ToString(CultureInfo.InvariantCulture));
                        if (!DnsEntries.Contains(ip))
                        {
                            int k = j;
                            manualEvents[k].Reset();
                            var scanner = new Thread(p => PortScanner(ports, ip, manualEvents[k]));
                            scanner.Start();

                            j = WaitHandle.WaitAny(manualEvents);
                            UISync.Execute(() => pbScanner.PerformStep());
                        }
                        if (_exiting)
                        {
                            break;
                        }
                    }
                    if (_exiting)
                    {
                        break;
                    }
                }
            }

            if (j > 0)
            {
                WaitHandle.WaitAll(manualEvents);
            }


            //populate MAC addresses
            try
            {
                var arpStream = ExecuteCommandLine("arp", "-a");
                // Consume first three lines
                for (int i = 0; i < 3; i++)
                {
                    arpStream.ReadLine();
                }
                // Read entries
                while (!arpStream.EndOfStream)
                {
                    var line = arpStream.ReadLine();
                    if (line != null)
                    {
                        line = line.Trim();
                        while (line.Contains("  "))
                        {
                            line = line.Replace("  ", " ");
                        }
                        var parts = line.Trim().Split(' ');

                        if (parts.Length == 3)
                        {
                            for (int i = 0; i < _dt.Rows.Count; i++)
                            {
                                DataRow dr = _dt.Rows[i];
                                string  ip = parts[0];
                                if (ip == dr["IP Address"].ToString().Split(':')[0])
                                {
                                    dr["MAC Address"] = parts[1];
                                }
                            }
                        }
                    }
                }
                _dt.AcceptChanges();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            UISync.Execute(ResetControls);
        }
Example #6
0
        private void RenderResources()
        {
            Text = LocRm.GetString("settings");
            btnColorArea.Text              = LocRm.GetString("AreaHighlight");
            btnColorBack.Text              = LocRm.GetString("ObjectBack");
            btnColorMain.Text              = LocRm.GetString("MainPanel");
            btnColorTracking.Text          = LocRm.GetString("Tracking");
            btnBorderHighlight.Text        = LocRm.GetString("BorderHighlight");
            btnColorVolume.Text            = LocRm.GetString("Level");
            btnDetectColor.Text            = LocRm.GetString("Activity");
            btnNoDetectColor.Text          = LocRm.GetString("NoActivity");
            button1.Text                   = LocRm.GetString("Ok");
            button2.Text                   = LocRm.GetString("Cancel");
            chkBalloon.Text                = LocRm.GetString("ShowBalloonTips");
            chkCheckForUpdates.Text        = LocRm.GetString("AutomaticallyCheckForUpda");
            chkErrorReporting.Text         = LocRm.GetString("AnonymousErrorReporting");
            chkPasswordProtect.Text        = LocRm.GetString("PasswordProtectWhenMinimi");
            chkShowGettingStarted.Text     = LocRm.GetString("ShowGettingStarted");
            chkStartup.Text                = LocRm.GetString("RunOnStartupthisUserOnly");
            chkAutoSchedule.Text           = LocRm.GetString("AutoApplySchedule");
            chkPasswordProtectOnStart.Text = LocRm.GetString("PasswordProtectOnStart");

            label14.Text = LocRm.GetString("IspyServerName");
            label16.Text = LocRm.GetString("ispyOpacitymayNotW");
            label2.Text  = LocRm.GetString("ServerReceiveTimeout");
            label21.Text = LocRm.GetString("TrayIconText");
            label3.Text  = LocRm.GetString("MediaDirectory");
            label4.Text  = "ms";
            label7.Text  = "ms";
            label8.Text  = LocRm.GetString("MjpegReceiveTimeout");

            label18.Text         = LocRm.GetString("MaxRecordingThreads");
            label13.Text         = LocRm.GetString("PlaybackMode");
            tabPage1.Text        = LocRm.GetString("Colors");
            tabPage2.Text        = LocRm.GetString("Storage");
            tabPage4.Text        = LocRm.GetString("Timeouts");
            tabPage6.Text        = LocRm.GetString("options");
            tabPage7.Text        = LocRm.GetString("IPAccess");
            linkLabel1.Text      = LocRm.GetString("GetLatestList");
            Text                 = LocRm.GetString("settings");
            linkLabel2.Text      = LocRm.GetString("HelpTranslateISpy");
            chkAlertWindows.Text = LocRm.GetString("CreateAlertWindow");
            chkOverlay.Text      = LocRm.GetString("ShowOverlayControls");
            lblPriority.Text     = LocRm.GetString("Priority");
            chkInterrupt.Text    = LocRm.GetString("InterruptScreensaverOnAlert");
            label23.Text         = LocRm.GetString("JPEGQuality");
            llblHelp.Text        = LocRm.GetString("help");
            label17.Text         = LocRm.GetString("IPAccessExplainer");
            chkMonitor.Text      = LocRm.GetString("RestartIfCrashed");
            chkGZip.Text         = LocRm.GetString("Enable GZip");
            label40.Text         = LocRm.GetString("Permissions");
            label24.Text         = LocRm.GetString("MediaPanelItems");
            label11.Text         = LocRm.GetString("ArchiveDirectory");
            label48.Text         = LocRm.GetString("DisconnectionNotificationDelay");
            label41.Text         = LocRm.GetString("MJPEGFrameInterval");
            label20.Text         = LocRm.GetString("VLCFileCache");
            label64.Text         = LocRm.GetString("HTTPReferrersAllowed");

            LocRm.SetString(lblMicrophone, "Microphone");
            LocRm.SetString(chkBigButtons, "BigButtons");
            LocRm.SetString(chkMinimise, "MinimiseOnClose");
            LocRm.SetString(chkRecycle, "DeleteToRecycle");
            LocRm.SetString(chkEnableIPv6, "EnableIPv6");
            LocRm.SetString(label15, "MaxCPUTarget");
            LocRm.SetString(label22, "MaxRedrawRate");
            LocRm.SetString(btnBorderDefault, "BorderDefault");
            LocRm.SetString(label25, "YouCanUseRegularExpressions");
            LocRm.SetString(tabPage5, "Talk");
            LocRm.SetString(tabPage8, "Joystick");
            LocRm.SetString(label26, "Joystick");
            LocRm.SetString(tabPage9, "Messaging");
            LocRm.SetString(label19, "AppendLinkText");

            LocRm.SetString(label28, "PanAxis");
            LocRm.SetString(label30, "TiltAxis");
            LocRm.SetString(label32, "ZoomAxis");
            LocRm.SetString(btnCenterAxes, "CenterAxes");


            LocRm.SetString(label34, "Record");
            LocRm.SetString(label29, "Snapshot");
            LocRm.SetString(label27, "Talk");
            LocRm.SetString(label31, "Listen");
            LocRm.SetString(label33, "Play");
            LocRm.SetString(label37, "Stop");
            LocRm.SetString(label35, "Next");
            LocRm.SetString(label36, "Previous");
            LocRm.SetString(label38, "JoystickNote");
            LocRm.SetString(label39, "StartupForm");
            LocRm.SetString(chkMinimiseToTray, "MinimiseToTray");

            LocRm.SetString(label56, "EmailNotifications");
            LocRm.SetString(label50, "EmailSubject");
            LocRm.SetString(label51, "EmailBody");
            LocRm.SetString(label19, "AppendLinkText");
            LocRm.SetString(label57, "SMSNotifications");
            LocRm.SetString(label54, "Message");
            LocRm.SetString(linkLabel5, "Reset");

            chkUseiSpy.Text = LocRm.GetString("UseISpyServers");
            label52.Text    = LocRm.GetString("FromAddress");
            label58.Text    = LocRm.GetString("Username");

            LocRm.SetString(label59, "Password");
            LocRm.SetString(label53, "Server");
            LocRm.SetString(label61, "Port");
            LocRm.SetString(chkSMTPUseSSL, "UseSSL");
            LocRm.SetString(btnTestSMTP, "Test");
            LocRm.SetString(label43, "WhenDisconnectedFromWebServices");
            LocRm.SetString(label45, "Execute");
            LocRm.SetString(label46, "Execute");
            LocRm.SetString(label44, "WhenReconnectedToWebServices");
            LocRm.SetString(label10, "Plugins");
            LocRm.SetString(linkLabel3, "DownloadPlugins");
            LocRm.SetString(linkLabel4, "RefreshList");
            tabPage10.Text = LocRm.GetString("ConnectionAlerts");
            tabPage11.Text = LocRm.GetString("Plugins");
            tabPage14.Text = LocRm.GetString("Logging");
            label9.Text    = LocRm.GetString("MaximseAndRestore");
            label60.Text   = LocRm.GetString("SSLCertificate");
            //future
            chkSpeechRecognition.Visible = false;
            label63.Text          = LocRm.GetString("Servers");
            chkOpenGrabs.Text     = LocRm.GetString("OpenImagesAfterSaving");
            chkEnableLogging.Text = LocRm.GetString("Enable");
            numKeepLogs.Text      = LocRm.GetString("KeepLogsForDays");
            numMaxLogSize.Text    = LocRm.GetString("MaxFileSizeKB");
            llblHelp.Visible      = linkLabel1.Visible = linkLabel2.Visible = Helper.HasFeature(Enums.Features.View_Ispy_Links);
        }
Example #7
0
        public void Play(string filename, string titleText)
        {
            if (InvokeRequired)
            {
                Invoke(new PlayDelegate(Play), filename, titleText);
            }
            else
            {
                if (!File.Exists(filename))
                {
                    MessageBox.Show(this, LocRm.GetString("FileNotFound") + Environment.NewLine + filename);
                    return;
                }
                _needsSize = _filename != filename;
                _filename  = filename;
                lock (_lock)
                {
                    _mMedia = _mFactory.CreateMedia <IMediaFromFile>(filename);
                    _mMedia.Events.DurationChanged += EventsDurationChanged;
                    _mMedia.Events.StateChanged    += EventsStateChanged;
                    _mMedia.Events.ParsedChanged   += Events_ParsedChanged;
                    try
                    {
                        _mPlayer.Open(_mMedia);
                        _mMedia.Parse(true);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogExceptionToFile(ex);
                        MessageBox.Show(this, LocRm.GetString("CouldNotOpen") + Environment.NewLine + filename);
                        return;
                    }

                    _mPlayer.Play();
                }

                string[]  parts = filename.Split('\\');
                string    fn    = parts[parts.Length - 1];
                FilesFile ff    = null;
                if (fn.EndsWith(".mp3") || fn.EndsWith(".wav"))
                {
                    var vl = ((MainForm)Owner).GetVolumeLevel(ObjectID);
                    if (vl != null)
                    {
                        ff = vl.FileList.FirstOrDefault(p => p.Filename.EndsWith(fn));
                    }
                    vNav.IsAudio             = true;
                    pnlMovie.BackgroundImage = Properties.Resources.ispy1audio;
                }
                else
                {
                    var cw = ((MainForm)Owner).GetCameraWindow(ObjectID);
                    if (cw != null)
                    {
                        ff = cw.FileList.FirstOrDefault(p => p.Filename.EndsWith(fn));
                    }
                    vNav.IsAudio             = false;
                    pnlMovie.BackgroundImage = Properties.Resources.ispy1;
                }

                if (ff != null)
                {
                    vNav.Init(ff);
                }
                Text = titleText;
            }
        }
Example #8
0
 public TagConfigure()
 {
     InitializeComponent();
     Text = LocRm.GetString("Tags");
 }
Example #9
0
        private bool ConfigureSchedule(objectsMicrophoneScheduleEntry sched)
        {
            if (ddlHourStart.SelectedItem.ToString() == "-" || ddlMinuteStart.SelectedItem.ToString() == "-")
            {
                sched.start = "-:-";
            }
            else
            {
                sched.start = ddlHourStart.SelectedItem + ":" + ddlMinuteStart.SelectedItem;
            }
            if (ddlHourEnd.SelectedItem.ToString() == "-" || ddlMinuteEnd.SelectedItem.ToString() == "-")
            {
                sched.stop = "-:-";
            }
            else
            {
                sched.stop = ddlHourEnd.SelectedItem + ":" + ddlMinuteEnd.SelectedItem;
            }

            sched.daysofweek = "";
            if (chkMon.Checked)
            {
                sched.daysofweek += "1,";
            }
            if (chkTue.Checked)
            {
                sched.daysofweek += "2,";
            }
            if (chkWed.Checked)
            {
                sched.daysofweek += "3,";
            }
            if (chkThu.Checked)
            {
                sched.daysofweek += "4,";
            }
            if (chkFri.Checked)
            {
                sched.daysofweek += "5,";
            }
            if (chkSat.Checked)
            {
                sched.daysofweek += "6,";
            }
            if (chkSun.Checked)
            {
                sched.daysofweek += "0,";
            }
            sched.daysofweek = sched.daysofweek.Trim(',');
            if (sched.daysofweek == "")
            {
                MessageBox.Show(LocRm.GetString("Validate_Camera_SelectOneDay")); //"Please select at least one day");
                return(false);
            }

            sched.recordonstart  = chkRecordSchedule.Checked;
            sched.active         = chkScheduleActive.Checked;
            sched.recordondetect = chkScheduleRecordOnDetect.Checked;
            sched.alerts         = chkScheduleAlerts.Checked;
            sched.messaging      = chkScheduleMessaging.Checked;
            return(true);
        }
Example #10
0
 private void RenderResources()
 {
     _btnOk.Text = LocRm.GetString("Ok");
     chkShowGettingStarted.Text = LocRm.GetString("ShowGettingStarted");
     Text = LocRm.GetString("GettingStarted");
 }
Example #11
0
        void FfmpegMergeProcessExited(object sender, EventArgs e)
        {
            if (_ffmpegProcess.ExitCode == 0)
            {
                if (_pbMerge.Count > 0)
                {
                    var ma = 0d;
                    var fi = new FileInfo(_dir + _outfile);


                    var alertData       = new StringBuilder();
                    int durationSeconds = 0;
                    foreach (var m in _pbMerge)
                    {
                        if (m.AlertData != "")
                        {
                            alertData.Append(m.AlertData);
                            alertData.Append(",");
                        }
                        durationSeconds += m.DurationSeconds;

                        if (m.MaxAlarm > ma)
                        {
                            ma = m.MaxAlarm;
                        }
                    }

                    var ff = new FilesFile
                    {
                        CreatedDateTicks     = DateTime.Now.Ticks,
                        DurationSeconds      = durationSeconds,
                        IsTimelapse          = false,
                        TriggerLevel         = _pbMerge.First().TriggerLevel,
                        TriggerLevelMax      = _pbMerge.First().TriggerLevelMax,
                        Filename             = _outfile,
                        AlertData            = Helper.GetMotionDataPoints(alertData),
                        MaxAlarm             = ma,
                        SizeBytes            = fi.Length,
                        IsMergeFile          = true,
                        IsMergeFileSpecified = true
                    };

                    string name;
                    if (_currentObject.Ot == 1)
                    {
                        var vl = MainClass.GetVolumeLevel(_currentObject.ID);
                        vl.AddFile(ff);
                        name = vl.Micobject.name;
                    }
                    else
                    {
                        var cw = MainClass.GetCameraWindow(_currentObject.ID);
                        cw.AddFile(ff);
                        name = cw.Camobject.name;

                        var fpv = _pbMerge.First();
                        //get preview image
                        string imgname = fpv.Filename.Substring(0,
                                                                fpv.Filename.LastIndexOf(".", StringComparison.Ordinal));
                        var imgpath = _dir + "thumbs/" + imgname + "_large.jpg";

                        if (File.Exists(imgpath))
                        {
                            Image bmpPreview = Image.FromFile(imgpath);

                            string jpgname = _dir + "thumbs\\" + ff.Filename.Substring(0,
                                                                                       ff.Filename.LastIndexOf(".", StringComparison.Ordinal));

                            bmpPreview.Save(jpgname + "_large.jpg", MainForm.Encoder,
                                            MainForm.EncoderParams);

                            Image.GetThumbnailImageAbort myCallback = ThumbnailCallback;
                            Image myThumbnail = bmpPreview.GetThumbnailImage(96, 72, myCallback, IntPtr.Zero);

                            myThumbnail.Save(jpgname + ".jpg", MainForm.Encoder,
                                             MainForm.EncoderParams);

                            myThumbnail.Dispose();
                            bmpPreview.Dispose();
                        }
                    }

                    var fp = new FilePreview(_outfile, durationSeconds, name, ff.CreatedDateTicks, _currentObject.Ot, _currentObject.ID, ma, false, true);
                    MainForm.MasterFileAdd(fp);
                    MainForm.NeedsMediaRefresh = Helper.Now;
                }
                _pbMerge.Clear();
            }
            else
            {
                MainForm.LogErrorToFile("FFMPEG process exited with code " + _ffmpegProcess.ExitCode);
                MessageBox.Show(this, LocRm.GetString("ErrorCheckLogFile"));
            }
            DoClose();
        }
        private void Troubleshooter()
        {
            //causes a reset of detected ip addresses
            MainForm.AddressIPv4 = MainForm.Conf.IPv4Address;
            MainForm.AddressIPv6 = MainForm.Conf.IPv6Address;

            UISync.Execute(() => rtbOutput.Clear());

            try
            {
                MainForm.StopAndStartServer();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            bool portMapOk = false;
            bool bIPv6     = MainForm.Conf.IPMode == "IPv6";

            UISync.Execute(() => button2.Enabled = false);



            string localserver = (MainForm.Conf.SSLEnabled?"https":"http") + "://" + MainForm.IPAddress + ":" + MainForm.Conf.LANPort;

            UISync.Execute(() => rtbOutput.Text = $"Local iSpy Server: {localserver}{NL}");
            if (webports.IndexOf("," + MainForm.Conf.LANPort + ",", StringComparison.Ordinal) == -1)
            {
                UISync.Execute(() => rtbOutput.Text +=
                                   $"Warning: Running a local server on a non-standard port ({MainForm.Conf.LANPort}) may cause web-browser security errors. Click the link above to test in your web browser.{NL}");
            }
            if (MainForm.IPAddress.StartsWith("169.254"))
            {
                UISync.Execute(() => rtbOutput.Text += NL + "Warning: Your network adaptor has assigned itself a link-local address (169.254.x.x). This means your PC is setup for DHCP but can't find a DHCP server and iSpy will be unavailable over your LAN. Try resetting your router." + NL);
            }
            if (MainForm.Conf.SSLEnabled)
            {
                UISync.Execute(() => rtbOutput.Text += "Warning: Using SSL - disable SSL in settings if you are having problems with connecting." + NL);
            }
            if (MainForm.Conf.SpecificIP)
            {
                UISync.Execute(
                    () =>
                    rtbOutput.Text +=
                        "Warning: You are binding to a specific IP address. This can cause issues on systems with multiple NICs. Try unchecking the Bind To IP Address option in settings/ web server if you have problems." +
                        NL);
            }

            UISync.Execute(() => rtbOutput.Text += "Checking local server... ");
            Application.DoEvents();
            string res = "";

            if (!loadurl(localserver, out res))
            {
                string res1 = res;
                UISync.Execute(() => rtbOutput.Text += $"Failed: {res1}{NL}");
                if (MainForm.MWS.Running)
                {
                    UISync.Execute(() => rtbOutput.Text += "Server reports it IS running" + NL);
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "Server reports it IS NOT running - check the log file for errors (View-> Log File)" + NL);
                }

                UISync.Execute(() => rtbOutput.Text += "Do you have a third party firewall or antivirus running (AVG/ zonealarm etc)?" + NL);
            }
            else
            {
                res = res.ToLower();
                if (res == "ok" || res.IndexOf("ispy", StringComparison.Ordinal) != -1)
                {
                    UISync.Execute(() => rtbOutput.Text += "OK");
                }
                else
                {
                    string res1 = res;
                    UISync.Execute(() => rtbOutput.Text += $"Unexpected output: {res1}");
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            UISync.Execute(() => rtbOutput.Text += "Checking WebServer... ");
            Application.DoEvents();
            if (!loadurl(MainForm.Webserver + "/webservices/ispyapi.asmx", out res))
            {
                UISync.Execute(() => rtbOutput.Text += "Webservices not responding.");
            }
            else
            {
                if (res.IndexOf("error occurred while", StringComparison.Ordinal) != -1)
                {
                    UISync.Execute(() => rtbOutput.Text += "Error with webservices. Please try again later (check your internet connection).");
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "OK");
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            UISync.Execute(() => rtbOutput.Text += "Checking your firewall... ");
            Application.DoEvents();
            try
            {
                var fw = new FireWall();
                fw.Initialize();

                bool bOn;
                var  r = fw.IsWindowsFirewallOn(out bOn);

                if (r == FireWall.FwErrorCode.FwNoerror)
                {
                    if (bOn)
                    {
                        string strApplication = Application.StartupPath + "\\iSpy.exe";
                        bool   bEnabled       = false;
                        fw.IsAppEnabled(strApplication, ref bEnabled);
                        if (!bEnabled)
                        {
                            UISync.Execute(
                                () =>
                                rtbOutput.Text +=
                                    "iSpy is *NOT ENABLED* - add ispy.exe to the windows firewall allowed list");
                        }
                        else
                        {
                            UISync.Execute(() => rtbOutput.Text += "iSpy is enabled");
                        }
                    }
                    else
                    {
                        UISync.Execute(() => rtbOutput.Text += "Firewall is off");
                    }
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "Firewall error: " + r);
                }
            }
            catch (Exception ex)
            {
                UISync.Execute(() => rtbOutput.Text += "Firewall error: " + ex.Message);
                UISync.Execute(() => rtbOutput.Text += NL + LocRm.GetString("AddFirewallExceptionManually"));
            }
            UISync.Execute(() => rtbOutput.Text += NL);


            UISync.Execute(() => rtbOutput.Text += "Checking your account... ");

            var result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, false);

            if (result[0] != "OK")
            {
                UISync.Execute(() => rtbOutput.Text += result[0]);
            }
            else
            {
                string[] result1 = result;
                UISync.Execute(() => rtbOutput.Text += "Found: " + result1[2]);
                if (Convert.ToBoolean(result[1]))
                {
                    UISync.Execute(() => rtbOutput.Text += NL + "Your subscription is valid." + NL);
                    if (MainForm.Conf.IPMode == "IPv4")
                    {
                        UISync.Execute(() => rtbOutput.Text += "IPv4: Checking port mappings... " + NL);
                        try
                        {
                            if (NATControl.Mappings == null)
                            {
                                UISync.Execute(
                                    () =>
                                    rtbOutput.Text +=
                                        "IPv4 Port mappings are unavailable - set up port mapping manually, instructions here: http://portforward.com/english/routers/port_forwarding/routerindex.htm" +
                                        NL);
                            }
                            else
                            {
                                int j = 2;
                                while (!portMapOk && j > 0)
                                {
                                    int maps = 0;
                                    try
                                    {
                                        var enumerator = NATControl.Mappings.GetEnumerator();
                                        while (enumerator.MoveNext())
                                        {
                                            var map = (NATUPNPLib.IStaticPortMapping)enumerator.Current;
                                            UISync.Execute(
                                                () =>
                                                rtbOutput.Text +=
                                                    map.ExternalPort + " -> " + map.InternalPort + " on " +
                                                    map.InternalClient +
                                                    " (" +
                                                    map.Protocol + ")" + NL);
                                            if (map.ExternalPort == MainForm.Conf.ServerPort)
                                            {
                                                if (map.InternalPort != MainForm.Conf.LANPort)
                                                {
                                                    UISync.Execute(
                                                        () =>
                                                        rtbOutput.Text +=
                                                            "*** External port is routing to " + map.InternalPort +
                                                            " instead of " +
                                                            MainForm.Conf.LANPort + NL);
                                                }
                                                else
                                                {
                                                    if (map.InternalClient != MainForm.AddressIPv4)
                                                    {
                                                        UISync.Execute(
                                                            () =>
                                                            rtbOutput.Text +=
                                                                "*** Port is mapping to IP Address " + map.InternalClient +
                                                                " - should be " +
                                                                MainForm.AddressIPv4 +
                                                                ". Set a static IP address for your computer and then update the port mapping." +
                                                                NL);
                                                    }
                                                    else
                                                    {
                                                        portMapOk = true;
                                                    }
                                                }
                                            }
                                            maps++;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        UISync.Execute(
                                            () => rtbOutput.Text += "Port mapping lookup failed (" + ex.Message.Trim() + "). If the connection fails try resetting your router or manually configure port forwarding. " + NL);
                                        if (maps == 0)
                                        {
                                            throw;
                                        }
                                    }
                                    if (!portMapOk)
                                    {
                                        //add port mapping
                                        UISync.Execute(() => rtbOutput.Text += "IPv4: Fixing port mapping... " + NL);
                                        if (!NATControl.SetPorts(MainForm.Conf.ServerPort, MainForm.Conf.LANPort))
                                        {
                                            UISync.Execute(
                                                () => rtbOutput.Text += LocRm.GetString("ErrorPortMapping") + NL);
                                        }

                                        j--;
                                        if (j > 0)
                                        {
                                            UISync.Execute(
                                                () => rtbOutput.Text += "IPv4: Checking port mappings... " + NL);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogException(ex);
                        }
                    }


                    UISync.Execute(() => rtbOutput.Text += "Checking external access... " + NL);

                    result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);

                    if (result.Length > 3 && result[3] != "")
                    {
                        MainForm.Conf.Loopback = MainForm.LoopBack = false;
                        UISync.Execute(() => rtbOutput.Text += "iSpyConnect is trying to contact your server at: " + result[6] + NL);
                        UISync.Execute(() => rtbOutput.Text += "Failed: " + result[3] + NL);
                        if (!bIPv6)
                        {
                            UISync.Execute(
                                () =>
                                rtbOutput.Text +=
                                    "Your router should be configured to forward TCP traffic from WAN (external) port " +
                                    MainForm.Conf.ServerPort + " to internal (LAN) port " +
                                    MainForm.Conf.LANPort + " on IP address " + MainForm.AddressIPv4 +
                                    NL);
                            if (portMapOk)
                            {
                                UISync.Execute(
                                    () =>
                                    rtbOutput.Text +=
                                        NL +
                                        "Your port mapping seems to be OK - try turning your router off and on again. Failing that we recommend checking with your ISP to see if they are blocking port " +
                                        MainForm.Conf.ServerPort +
                                        " or check if your antivirus protection (eset, zonealarm etc) is blocking iSpy. ");
                            }
                        }

                        if (MainForm.AddressListIPv4.Length > 1)
                        {
                            UISync.Execute(() => rtbOutput.Text += NL + "Warning: There are multiple network adaptors in your PC. Try selecting a different IP address to listen on in iSpy web settings or disable unused network adaptors and restart iSpy: " + NL);
                            foreach (var ip in MainForm.AddressListIPv4)
                            {
                                string ip1 = ip.ToString();
                                if (ip1 != MainForm.IPAddress)
                                {
                                    UISync.Execute(() => rtbOutput.Text += "\t" + ip1 + NL);
                                }
                            }
                        }
                        UISync.Execute(() => rtbOutput.Text += NL + NL + "Please see the troubleshooting section here: http://www.ispyconnect.com/userguide-remote-access-troubleshooting.aspx");
                    }
                    else
                    {
                        if (result.Length == 1)
                        {
                            UISync.Execute(() => rtbOutput.Text +=
                                               "Failed: Communication with webserver failed." + NL + NL);
                        }
                        else
                        {
                            UISync.Execute(() => rtbOutput.Text +=
                                               "Success!" + NL + NL + "If you cannot access content locally please ensure 'Use LAN IP when available' is checked on " + MainForm.Webserver + "/account.aspx and also ensure you're using an up to date web browser (we recommend google Chrome)");

                            MainForm.Conf.Loopback = MainForm.LoopBack = true;
                        }
                    }
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += NL +
                                                           "Not subscribed - local access only. http://www.ispyconnect.com/subscribe.aspx");
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            Application.DoEvents();
            UISync.Execute(() => button2.Enabled = true);
        }
Example #13
0
 private void PTZTool_Load(object sender, EventArgs e)
 {
     Text = LocRm.GetString("PTZTool");
 }
Example #14
0
 public Prompt()
 {
     InitializeComponent();
     button1.Text = LocRm.GetString("OK");
 }
Example #15
0
        private void SettingsLoad(object sender, EventArgs e)
        {
            if (!Helper.HasFeature(Enums.Features.Settings))
            {
                using (var cp = new CheckPassword())
                {
                    cp.ShowDialog(this);
                }
            }

            if (!Helper.HasFeature(Enums.Features.Settings))
            {
                MessageBox.Show(this, LocRm.GetString("AccessDenied"));
                Close();
                return;
            }

            UISync.Init(this);
            tcTabs.SelectedIndex       = InitialTab;
            chkErrorReporting.Checked  = MainForm.Conf.Enable_Error_Reporting;
            chkCheckForUpdates.Checked = MainForm.Conf.Enable_Update_Check;

            chkShowGettingStarted.Checked = MainForm.Conf.Enabled_ShowGettingStarted;
            _rkApp             = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", false);
            chkStartup.Checked = (_rkApp != null && _rkApp.GetValue("iSpy") != null);

            mediaDirectoryEditor1.Init(MainForm.Conf.MediaDirectories);

            btnDetectColor.BackColor     = MainForm.Conf.ActivityColor.ToColor();
            btnNoDetectColor.BackColor   = MainForm.Conf.NoActivityColor.ToColor();
            btnColorTracking.BackColor   = MainForm.Conf.TrackingColor.ToColor();
            btnColorVolume.BackColor     = MainForm.Conf.VolumeLevelColor.ToColor();
            btnColorMain.BackColor       = MainForm.Conf.MainColor.ToColor();
            btnColorArea.BackColor       = MainForm.Conf.AreaColor.ToColor();
            btnColorBack.BackColor       = MainForm.Conf.BackColor.ToColor();
            btnBorderHighlight.BackColor = MainForm.Conf.BorderHighlightColor.ToColor();
            btnBorderDefault.BackColor   = MainForm.Conf.BorderDefaultColor.ToColor();
            chkAutoSchedule.Checked      = MainForm.Conf.AutoSchedule;
            numMaxCPU.Value = MainForm.Conf.CPUMax;
            numMaxRecordingThreads.Value = MainForm.Conf.MaxRecordingThreads;
            numRedraw.Value              = MainForm.Conf.MaxRedrawRate;
            numMediaPanelItems.Value     = MainForm.Conf.PreviewItems;
            txtTrayIcon.Text             = MainForm.Conf.TrayIconText;
            chkMinimise.Checked          = MainForm.Conf.MinimiseOnClose;
            chkSpeechRecognition.Checked = MainForm.Conf.SpeechRecognition;
            chkMinimiseToTray.Checked    = MainForm.Conf.TrayOnMinimise;

            if (chkMonitor.Checked && !MainForm.Conf.Monitor)
            {
                Process.Start(Program.AppPath + "iSpyMonitor.exe");
            }
            chkMonitor.Checked = MainForm.Conf.Monitor;

            tbOpacity.Value = MainForm.Conf.Opacity;
            SetColors();

            chkBalloon.Checked = MainForm.Conf.BalloonTips;

            txtIPCameraTimeout.Value      = MainForm.Conf.IPCameraTimeout;
            txtServerReceiveTimeout.Value = MainForm.Conf.ServerReceiveTimeout;
            txtServerName.Text            = MainForm.Conf.ServerName;
            rtbAccessList.Text            = MainForm.Conf.AllowedIPList;

            int i = 0, selind = 0;

            foreach (TranslationsTranslationSet set in LocRm.TranslationSets.OrderBy(p => p.Name))
            {
                ddlLanguage.Items.Add(new ListItem(set.Name, new[] { set.CultureCode }));
                if (set.CultureCode == MainForm.Conf.Language)
                {
                    selind = i;
                }
                i++;
            }
            ddlLanguage.SelectedIndex    = selind;
            chkAlertWindows.Checked      = MainForm.Conf.CreateAlertWindows;
            chkOverlay.Checked           = MainForm.Conf.ShowOverlayControls;
            chkInterrupt.Checked         = MainForm.Conf.ScreensaverWakeup;
            chkEnableIPv6.Checked        = !MainForm.Conf.IPv6Disabled;
            chkRecycle.Checked           = MainForm.Conf.DeleteToRecycleBin;
            txtAppendLinkText.Text       = MainForm.Conf.AppendLinkText;
            numMJPEGStreamInterval.Value = MainForm.Conf.MJPEGStreamInterval;
            txtAlertOnDisconnect.Text    = MainForm.Conf.AlertOnDisconnect;
            txtAlertOnReconnect.Text     = MainForm.Conf.AlertOnReconnect;
            txtArchive.Text = MainForm.Conf.Archive;
            SetSSLText();


            txtAlertSubject.Text = MainForm.Conf.MailAlertSubject;
            txtAlertBody.Text    = MainForm.Conf.MailAlertBody;
            txtSMSBody.Text      = MainForm.Conf.SMSAlert;

            foreach (string s in StartupModes)
            {
                ddlStartupMode.Items.Add(LocRm.GetString(s));
            }

            foreach (string s in Priorities)
            {
                ddlPriority.Items.Add(LocRm.GetString(s));
            }
            ddlStartupMode.SelectedIndex = MainForm.Conf.StartupMode;

            foreach (var grid in MainForm.Conf.GridViews)
            {
                ddlStartUpForm.Items.Add(grid.name);
            }

            ddlPriority.SelectedIndex = MainForm.Conf.Priority - 1;

            ddlStartUpForm.SelectedItem = MainForm.Conf.StartupForm;
            if (ddlStartUpForm.SelectedItem == null)
            {
                ddlStartUpForm.SelectedIndex = 0;
            }

            ddlPlayback.Items.AddRange(PlaybackModes);

            if (MainForm.Conf.PlaybackMode < 0)
            {
                MainForm.Conf.PlaybackMode = 0;
            }

            if (MainForm.Conf.PlaybackMode < ddlPlayback.Items.Count)
            {
                ddlPlayback.SelectedIndex = MainForm.Conf.PlaybackMode;
            }
            try
            {
                numJPEGQuality.Value = MainForm.Conf.JPEGQuality;
            }
            catch (Exception)
            {
            }
            chkBigButtons.Checked = MainForm.Conf.BigButtons;

            selind = -1;
            i      = 1;
            try
            {
                ddlTalkMic.Items.Add(LocRm.GetString("None"));

                for (int n = 0; n < WaveIn.DeviceCount; n++)
                {
                    ddlTalkMic.Items.Add(WaveIn.GetCapabilities(n).ProductName);
                    if (WaveIn.GetCapabilities(n).ProductName == MainForm.Conf.TalkMic)
                    {
                        selind = i;
                    }
                    i++;
                }
                ddlTalkMic.Enabled = true;
                if (selind > -1)
                {
                    ddlTalkMic.SelectedIndex = selind;
                }
                else
                {
                    if (ddlTalkMic.Items.Count == 1)
                    {
                        ddlTalkMic.Items.Add(_noDevices);
                        ddlTalkMic.Enabled       = false;
                        ddlTalkMic.SelectedIndex = 1;
                    }
                    else
                    {
                        ddlTalkMic.SelectedIndex = 0;
                    }
                }
            }
            catch (ApplicationException ex)
            {
                MainForm.LogExceptionToFile(ex);
                ddlTalkMic.Items.Add(_noDevices);
                ddlTalkMic.Enabled = false;
            }

            ddlJoystick.Items.Add(LocRm.GetString("None"));

            _jst = new JoystickDevice();
            var ij = 0;

            _sticks = _jst.FindJoysticks();
            i       = 1;
            foreach (string js in _sticks)
            {
                var nameid = js.Split('|');
                ddlJoystick.Items.Add(nameid[0]);
                if (nameid[1] == MainForm.Conf.Joystick.id)
                {
                    ij = i;
                }
                i++;
            }

            ddlJoystick.SelectedIndex = ij;


            jaxis1.ID          = MainForm.Conf.Joystick.XAxis;
            jaxis1.SupportDPad = true;
            jaxis1.Invert      = MainForm.Conf.Joystick.InvertXAxis;

            jaxis2.ID     = MainForm.Conf.Joystick.YAxis;
            jaxis2.Invert = MainForm.Conf.Joystick.InvertYAxis;

            jaxis3.ID     = MainForm.Conf.Joystick.ZAxis;
            jaxis3.Invert = MainForm.Conf.Joystick.InvertZAxis;

            jbutton1.ID = MainForm.Conf.Joystick.Record;
            jbutton2.ID = MainForm.Conf.Joystick.Snapshot;
            jbutton3.ID = MainForm.Conf.Joystick.Talk;
            jbutton4.ID = MainForm.Conf.Joystick.Listen;
            jbutton5.ID = MainForm.Conf.Joystick.Play;
            jbutton6.ID = MainForm.Conf.Joystick.Next;
            jbutton7.ID = MainForm.Conf.Joystick.Previous;
            jbutton8.ID = MainForm.Conf.Joystick.Stop;
            jbutton9.ID = MainForm.Conf.Joystick.MaxMin;

            jbutton1.GetInput += JbuttonGetInput;
            jbutton2.GetInput += JbuttonGetInput;
            jbutton3.GetInput += JbuttonGetInput;
            jbutton4.GetInput += JbuttonGetInput;
            jbutton5.GetInput += JbuttonGetInput;
            jbutton6.GetInput += JbuttonGetInput;
            jbutton7.GetInput += JbuttonGetInput;
            jbutton8.GetInput += JbuttonGetInput;
            jbutton9.GetInput += JbuttonGetInput;

            jaxis1.GetInput += JaxisGetInput;
            jaxis2.GetInput += JaxisGetInput;
            jaxis3.GetInput += JaxisGetInput;

            chkGZip.Checked = MainForm.Conf.EnableGZip;
            numDisconnectNotification.Value = MainForm.Conf.DisconnectNotificationDelay;
            mediaDirectoryEditor1.Enabled   = Helper.HasFeature(Enums.Features.Storage);
            HideTab(tabPage11, Helper.HasFeature(Enums.Features.Plugins));

            //important leave here:
            chkPasswordProtect.Checked = MainForm.Conf.Enable_Password_Protect;
            if (Helper.HasFeature(Enums.Features.Plugins))
            {
                ListPlugins();
            }

            chkUseiSpy.Checked      = !MainForm.Conf.UseSMTP;
            txtSMTPFromAddress.Text = MainForm.Conf.SMTPFromAddress;
            txtSMTPUsername.Text    = MainForm.Conf.SMTPUsername;
            txtSMTPPassword.Text    = MainForm.Conf.SMTPPassword;
            txtSMTPServer.Text      = MainForm.Conf.SMTPServer;
            chkSMTPUseSSL.Checked   = MainForm.Conf.SMTPSSL;
            numSMTPPort.Value       = MainForm.Conf.SMTPPort;

            ftpEditor1.Init(MainForm.Conf.FTPServers);
            chkOpenGrabs.Checked = MainForm.Conf.OpenGrabs;
            numFileCache.Value   = MainForm.Conf.VLCFileCache;
            rtbReferrers.Text    = MainForm.Conf.Referers;
            chkPasswordProtectOnStart.Checked = MainForm.Conf.Password_Protect_Startup;

            chkEnableLogging.Checked = MainForm.Conf.Logging.Enabled;
            numMaxLogSize.Value      = MainForm.Conf.Logging.FileSize;
            numKeepLogs.Value        = MainForm.Conf.Logging.KeepDays;

            _loaded = true;
        }
        private void Troubleshooter()
        {
            UISync.Execute(() => rtbOutput.Clear());

            try
            {
                MainForm.StopAndStartServer();
            }
            catch (Exception ex)
            {
                MainForm.LogExceptionToFile(ex);
            }

            bool portMapOk = false;
            bool IPv6      = MainForm.Conf.IPMode == "IPv6";

            UISync.Execute(() => button2.Enabled = false);



            string localserver = "http://" + MainForm.IPAddress + ":" + MainForm.Conf.LANPort;

            UISync.Execute(() => rtbOutput.Text = "Local iSpy Server: " + localserver + NL);
            if (MainForm.Conf.LANPort != 8080)
            {
                UISync.Execute(() => rtbOutput.Text +=
                                   "--Warning, running a local server on a non-standard port (" + MainForm.Conf.LANPort + ") may cause web-browser security errors. Click the link above to test in your web browser." +
                                   NL);
            }
            UISync.Execute(() => rtbOutput.Text += "Checking local server... ");
            Application.DoEvents();
            string res = "";

            if (!loadurl(localserver + "/ping", out res))
            {
                UISync.Execute(() => rtbOutput.Text += "Failed: " + res + NL);
                if (MainForm.MWS.Running)
                {
                    UISync.Execute(() => rtbOutput.Text += "Server reports it IS running" + NL);
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "Server reports it IS NOT running - check the log file for errors (View-> Log File)" + NL);
                }

                UISync.Execute(() => rtbOutput.Text += "Do you have a third party firewall or antivirus running (AVG/ zonealarm etc)?" + NL);
            }
            else
            {
                res = res.ToLower();
                if (res.IndexOf("access") != -1 || res.IndexOf("ok") != -1)
                {
                    UISync.Execute(() => rtbOutput.Text += "OK");
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "Unexpected output: " + res);
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            UISync.Execute(() => rtbOutput.Text += "Checking WebServer... ");
            Application.DoEvents();
            if (!loadurl(MainForm.Webserver + "/webservices/ispy.asmx", out res))
            {
                UISync.Execute(() => rtbOutput.Text += "Webservices not responding.");
            }
            else
            {
                if (res.IndexOf("error occurred while") != -1)
                {
                    UISync.Execute(() => rtbOutput.Text += "Error with webservices. Please try again later.");
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "OK");
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            UISync.Execute(() => rtbOutput.Text += "Checking your firewall... ");
            Application.DoEvents();
            var fw = new WinXPSP2FireWall();

            fw.Initialize();

            bool bOn = false;

            fw.IsWindowsFirewallOn(ref bOn);
            if (bOn)
            {
                string strApplication = Application.StartupPath + "\\iSpy.exe";
                bool   bEnabled       = false;
                fw.IsAppEnabled(strApplication, ref bEnabled);
                if (!bEnabled)
                {
                    UISync.Execute(() => rtbOutput.Text += "iSpy is *not* enabled");
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += "iSpy is enabled");
                }
            }
            else
            {
                UISync.Execute(() => rtbOutput.Text += "Firewall is off");
            }
            UISync.Execute(() => rtbOutput.Text += NL);


            UISync.Execute(() => rtbOutput.Text += "Checking your account... ");

            var result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, false);

            if (result[0] != "OK")
            {
                UISync.Execute(() => rtbOutput.Text += result[0]);
            }
            else
            {
                UISync.Execute(() => rtbOutput.Text += "Found: " + result[2]);
                if (Convert.ToBoolean(result[1]))
                {
                    UISync.Execute(() => rtbOutput.Text += NL + "Your subscription is valid." + NL);
                    if (MainForm.Conf.IPMode == "IPv4")
                    {
                        UISync.Execute(() => rtbOutput.Text += "IPv4: Checking port mappings... " + NL);
                        try
                        {
                            if (NATControl.Mappings == null)
                            {
                                UISync.Execute(
                                    () =>
                                    rtbOutput.Text +=
                                        "IPv4 Port mappings are unavailable - set up port mapping manually, instructions here: http://portforward.com/english/routers/port_forwarding/routerindex.htm" +
                                        NL);
                            }
                            else
                            {
                                int j = 2;
                                while (!portMapOk && j > 0)
                                {
                                    var enumerator = NATControl.Mappings.GetEnumerator();

                                    while (enumerator.MoveNext())
                                    {
                                        var map = (NATUPNPLib.IStaticPortMapping)enumerator.Current;
                                        UISync.Execute(
                                            () =>
                                            rtbOutput.Text +=
                                                map.ExternalPort + " -> " + map.InternalPort + " on " + map.InternalClient +
                                                " (" +
                                                map.Protocol + ")" + NL);
                                        if (map.ExternalPort == MainForm.Conf.ServerPort)
                                        {
                                            if (map.InternalPort != MainForm.Conf.LANPort)
                                            {
                                                UISync.Execute(
                                                    () =>
                                                    rtbOutput.Text +=
                                                        "*** External port is routing to " + map.InternalPort +
                                                        " instead of " +
                                                        MainForm.Conf.LANPort + NL);
                                            }
                                            else
                                            {
                                                if (map.InternalClient != MainForm.AddressIPv4)
                                                {
                                                    UISync.Execute(
                                                        () =>
                                                        rtbOutput.Text +=
                                                            "*** Port is mapping to IP Address " + map.InternalClient +
                                                            " - should be " +
                                                            MainForm.AddressIPv4 +
                                                            ". Set a static IP address for your computer and then update the port mapping." +
                                                            NL);
                                                }
                                                else
                                                {
                                                    portMapOk = true;
                                                }
                                            }
                                        }
                                    }
                                    if (!portMapOk)
                                    {
                                        //add port mapping
                                        UISync.Execute(() => rtbOutput.Text += "IPv4: Fixing port mapping... " + NL);
                                        if (!NATControl.SetPorts(MainForm.Conf.ServerPort, MainForm.Conf.LANPort))
                                        {
                                            UISync.Execute(
                                                () => rtbOutput.Text += LocRm.GetString("ErrorPortMapping") + NL);
                                        }

                                        j--;
                                        if (j > 0)
                                        {
                                            UISync.Execute(
                                                () => rtbOutput.Text += "IPv4: Checking port mappings... " + NL);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MainForm.LogExceptionToFile(ex);
                        }
                    }


                    UISync.Execute(() => rtbOutput.Text += "Checking external access... " + NL);

                    result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);

                    if (result.Length > 3 && result[3] != "")
                    {
                        UISync.Execute(() => rtbOutput.Text += "iSpyConnect is trying to contact your server at: " + result[6] + NL);
                        UISync.Execute(() => rtbOutput.Text += "Failed: " + result[3] + NL);
                        if (!IPv6)
                        {
                            UISync.Execute(
                                () =>
                                rtbOutput.Text +=
                                    "Your router should be configured to forward TCP traffic from WAN (external) port " +
                                    MainForm.Conf.ServerPort + " to internal (LAN) port " +
                                    MainForm.Conf.LANPort + " on IP address " + MainForm.AddressIPv4 +
                                    NL);
                            UISync.Execute(
                                () =>
                                rtbOutput.Text +=
                                    "Check http://www.ispyconnect.com/userguide-connecting.aspx#6 for troubleshooting.");
                            if (portMapOk)
                            {
                                UISync.Execute(
                                    () =>
                                    rtbOutput.Text +=
                                        NL +
                                        "Your port mapping seems to be OK - try turning your router off and on again. Failing that we recommend checking with your ISP to see if they are blocking port " +
                                        MainForm.Conf.ServerPort +
                                        " or check if your antivirus protection (eset, zonealarm etc) is blocking iSpy. ");
                            }
                        }
                        UISync.Execute(() => rtbOutput.Text += NL + NL + "If you still cannot get it working, please see the troubleshooting section here: http://www.ispyconnect.com/userguide-remote-access-troubleshooting.aspx");
                    }
                    else
                    {
                        if (result.Length == 1)
                        {
                            UISync.Execute(() => rtbOutput.Text +=
                                               "Failed: Communication with webserver failed." + NL + NL);
                        }
                        else
                        {
                            UISync.Execute(() => rtbOutput.Text +=
                                               "Success!" + NL + NL + "If you cannot access content locally please ensure 'Use LAN IP when available' is checked on " + MainForm.Webserver + "/account.aspx and also ensure you're using an up to date web browser (we recommend google Chrome. Opera is incompatible)");
                        }
                    }
                }
                else
                {
                    UISync.Execute(() => rtbOutput.Text += NL +
                                                           "Not subscribed - local access only. http://www.ispyconnect.com/subscribe.aspx");
                }
            }
            UISync.Execute(() => rtbOutput.Text += NL);
            Application.DoEvents();
            UISync.Execute(() => button2.Enabled = true);
        }
Example #17
0
        private void Button1Click(object sender, EventArgs e)
        {
            string err = "";

            foreach (var s in mediaDirectoryEditor1.Directories)
            {
                if (!Directory.Exists(s.Entry))
                {
                    err += LocRm.GetString("Validate_MediaDirectory") + " (" + s.Entry + ")\n";
                    break;
                }
            }

            if (err != "")
            {
                MessageBox.Show(err, LocRm.GetString("Error"));
                return;
            }

            if (numJPEGQuality.Value != MainForm.Conf.JPEGQuality)
            {
                MainForm.EncoderParams.Param[0] = new EncoderParameter(Encoder.Quality, (int)numJPEGQuality.Value);
            }
            MainForm.Conf.Enable_Error_Reporting  = chkErrorReporting.Checked;
            MainForm.Conf.Enable_Update_Check     = chkCheckForUpdates.Checked;
            MainForm.Conf.Enable_Password_Protect = chkPasswordProtect.Checked;

            MainForm.Conf.NoActivityColor      = btnNoDetectColor.BackColor.ToRGBString();
            MainForm.Conf.ActivityColor        = btnDetectColor.BackColor.ToRGBString();
            MainForm.Conf.TrackingColor        = btnColorTracking.BackColor.ToRGBString();
            MainForm.Conf.VolumeLevelColor     = btnColorVolume.BackColor.ToRGBString();
            MainForm.Conf.MainColor            = btnColorMain.BackColor.ToRGBString();
            MainForm.Conf.AreaColor            = btnColorArea.BackColor.ToRGBString();
            MainForm.Conf.BackColor            = btnColorBack.BackColor.ToRGBString();
            MainForm.Conf.BorderHighlightColor = btnBorderHighlight.BackColor.ToRGBString();
            MainForm.Conf.BorderDefaultColor   = btnBorderDefault.BackColor.ToRGBString();

            MainForm.Conf.Enabled_ShowGettingStarted = chkShowGettingStarted.Checked;
            MainForm.Conf.Opacity              = tbOpacity.Value;
            MainForm.Conf.OpenGrabs            = chkOpenGrabs.Checked;
            MainForm.Conf.BalloonTips          = chkBalloon.Checked;
            MainForm.Conf.TrayIconText         = txtTrayIcon.Text;
            MainForm.Conf.IPCameraTimeout      = Convert.ToInt32(txtIPCameraTimeout.Value);
            MainForm.Conf.ServerReceiveTimeout = Convert.ToInt32(txtServerReceiveTimeout.Value);
            MainForm.Conf.ServerName           = txtServerName.Text;
            MainForm.Conf.AutoSchedule         = chkAutoSchedule.Checked;
            MainForm.Conf.CPUMax = Convert.ToInt32(numMaxCPU.Value);
            MainForm.Conf.MaxRecordingThreads         = (int)numMaxRecordingThreads.Value;
            MainForm.Conf.CreateAlertWindows          = chkAlertWindows.Checked;
            MainForm.Conf.MaxRedrawRate               = (int)numRedraw.Value;
            MainForm.Conf.Priority                    = ddlPriority.SelectedIndex + 1;
            MainForm.Conf.Monitor                     = chkMonitor.Checked;
            MainForm.Conf.ScreensaverWakeup           = chkInterrupt.Checked;
            MainForm.Conf.PlaybackMode                = ddlPlayback.SelectedIndex;
            MainForm.Conf.PreviewItems                = (int)numMediaPanelItems.Value;
            MainForm.Conf.BigButtons                  = chkBigButtons.Checked;
            MainForm.Conf.DeleteToRecycleBin          = chkRecycle.Checked;
            MainForm.Conf.SpeechRecognition           = chkSpeechRecognition.Checked;
            MainForm.Conf.AppendLinkText              = txtAppendLinkText.Text;
            MainForm.Conf.StartupForm                 = ddlStartUpForm.SelectedItem.ToString();
            MainForm.Conf.TrayOnMinimise              = chkMinimiseToTray.Checked;
            MainForm.Conf.MJPEGStreamInterval         = (int)numMJPEGStreamInterval.Value;
            MainForm.Conf.AlertOnDisconnect           = txtAlertOnDisconnect.Text;
            MainForm.Conf.AlertOnReconnect            = txtAlertOnReconnect.Text;
            MainForm.Conf.StartupMode                 = ddlStartupMode.SelectedIndex;
            MainForm.Conf.EnableGZip                  = chkGZip.Checked;
            MainForm.Conf.DisconnectNotificationDelay = (int)numDisconnectNotification.Value;
            var l = mediaDirectoryEditor1.Directories.ToList();

            MainForm.Conf.MediaDirectories = l.ToArray();
            var l2 = ftpEditor1.Servers.ToList();

            MainForm.Conf.FTPServers               = l2.ToArray();
            MainForm.Conf.MailAlertSubject         = txtAlertSubject.Text;
            MainForm.Conf.MailAlertBody            = txtAlertBody.Text;
            MainForm.Conf.SMSAlert                 = txtSMSBody.Text;
            MainForm.Conf.VLCFileCache             = (int)numFileCache.Value;
            MainForm.Conf.Password_Protect_Startup = chkPasswordProtectOnStart.Checked;
            SaveSMTPSettings();

            MainForm.Conf.Archive = txtArchive.Text.Trim();
            if (!string.IsNullOrEmpty(MainForm.Conf.Archive))
            {
                if (!MainForm.Conf.Archive.EndsWith(@"\"))
                {
                    MainForm.Conf.Archive += @"\";
                }
                if (!Directory.Exists(MainForm.Conf.Archive))
                {
                    MainForm.Conf.Archive = "";
                    MainForm.LogErrorToFile("Archive directory ignored - couldn't be found on disk");
                }
            }

            MainForm.Iconfont = new Font(FontFamily.GenericSansSerif, MainForm.Conf.BigButtons ? 22 : 15, FontStyle.Bold, GraphicsUnit.Pixel);

            MainForm.Conf.TalkMic = "";
            if (ddlTalkMic.Enabled)
            {
                if (ddlTalkMic.SelectedIndex > 0)
                {
                    MainForm.Conf.TalkMic = ddlTalkMic.SelectedItem.ToString();
                }
            }

            MainForm.Conf.MinimiseOnClose = chkMinimise.Checked;
            MainForm.Conf.JPEGQuality     = (int)numJPEGQuality.Value;
            MainForm.Conf.IPv6Disabled    = !chkEnableIPv6.Checked;

            MainForm.SetPriority();

            var ips = rtbAccessList.Text.Trim().Split(',');
            var t   = ips.Select(ip => ip.Trim()).Where(ip2 => ip2 != "").Aggregate("", (current, ip2) => current + (ip2 + ","));

            MainForm.Conf.AllowedIPList = t.Trim(',');
            LocalServer.AllowedIPs      = null;

            var refs = rtbReferrers.Text.Trim().Split(',');
            var t2   = refs.Select(ip => ip.Trim()).Where(ip2 => ip2 != "").Aggregate("", (current, ip2) => current + (ip2 + ","));

            MainForm.Conf.Referers      = t2.Trim(',');
            LocalServer.AllowedReferers = null;


            MainForm.Conf.ShowOverlayControls = chkOverlay.Checked;

            string lang = ((ListItem)ddlLanguage.SelectedItem).Value[0];

            if (lang != MainForm.Conf.Language)
            {
                ReloadResources = true;
                LocRm.Reset();
            }
            MainForm.Conf.Language = lang;
            if (chkStartup.Checked)
            {
                try
                {
                    _rkApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    _rkApp?.SetValue("iSpy", "\"" + Application.ExecutablePath + "\" -silent", RegistryValueKind.String);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MainForm.LogExceptionToFile(ex);
                }
            }
            else
            {
                try
                {
                    _rkApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    _rkApp?.DeleteValue("iSpy", false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MainForm.LogExceptionToFile(ex);
                }
            }

            //SetStorageOptions();

            MainForm.ReloadColors();

            if (ddlJoystick.SelectedIndex > 0)
            {
                string nameid = _sticks[ddlJoystick.SelectedIndex - 1];
                MainForm.Conf.Joystick.id = nameid.Split('|')[1];

                MainForm.Conf.Joystick.XAxis = jaxis1.ID;

                MainForm.Conf.Joystick.InvertXAxis = jaxis1.Invert;

                MainForm.Conf.Joystick.YAxis       = jaxis2.ID;
                MainForm.Conf.Joystick.InvertYAxis = jaxis2.Invert;

                MainForm.Conf.Joystick.ZAxis       = jaxis3.ID;
                MainForm.Conf.Joystick.InvertZAxis = jaxis3.Invert;

                MainForm.Conf.Joystick.Record   = jbutton1.ID;
                MainForm.Conf.Joystick.Snapshot = jbutton2.ID;
                MainForm.Conf.Joystick.Talk     = jbutton3.ID;
                MainForm.Conf.Joystick.Listen   = jbutton4.ID;
                MainForm.Conf.Joystick.Play     = jbutton5.ID;
                MainForm.Conf.Joystick.Next     = jbutton6.ID;
                MainForm.Conf.Joystick.Previous = jbutton7.ID;
                MainForm.Conf.Joystick.Stop     = jbutton8.ID;
                MainForm.Conf.Joystick.MaxMin   = jbutton9.ID;
            }
            else
            {
                MainForm.Conf.Joystick.id = "";
            }

            MainForm.Conf.Logging.Enabled  = chkEnableLogging.Checked;
            MainForm.Conf.Logging.FileSize = (int)numMaxLogSize.Value;
            MainForm.Conf.Logging.KeepDays = (int)numKeepLogs.Value;

            DialogResult = DialogResult.OK;
            Close();
        }
Example #18
0
        private void InitLogging(bool warnonerror = true)
        {
            DateTime logdate = DateTime.Now;

            foreach (string s in Directory.GetFiles(Program.AppDataPath, "log_*", SearchOption.TopDirectoryOnly))
            {
                var fi = new FileInfo(s);
                if (fi.CreationTime < Helper.Now.AddDays(0 - Conf.Logging.KeepDays))
                {
                    FileOperations.Delete(s);
                }
            }
            NextLog = Zeropad(logdate.Day) + Zeropad(logdate.Month) + logdate.Year;
            int i = 1;

            if (File.Exists(Program.AppDataPath + "log_" + NextLog + ".htm"))
            {
                while (File.Exists(Program.AppDataPath + "log_" + NextLog + "_" + i + ".htm"))
                {
                    i++;
                }
                NextLog += "_" + i;
            }
            try
            {
                File.WriteAllText(Program.AppDataPath + "log_" + NextLog + ".htm", Helper.Now + Environment.NewLine);
                _logging = true;
            }
            catch (Exception ex)
            {
                if (warnonerror && MessageBox.Show(LocRm.GetString("LogStartError").Replace("[MESSAGE]", ex.Message), LocRm.GetString("Warning"), MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    ShuttingDown = true;
                    Close();
                }
            }
        }
Example #19
0
        public static string AlertSummary(objectsActionsEntry e)
        {
            string t = "Unknown";
            bool   b;

            switch (e.type.ToUpperInvariant())
            {
            case "EXE":
                t = LocRm.GetString("ExecuteFile") + ": " + e.param1;
                break;

            case "URL":
                t = LocRm.GetString("CallURL") + ": " + e.param1;
                Boolean.TryParse(e.param2, out b);
                if (b)
                {
                    t += " (POST grab)";
                }
                break;

            case "NM":
                t = e.param1 + " " + e.param2 + ":" + e.param3 + " (" + e.param4 + ")";
                break;

            case "S":
                t = LocRm.GetString("PlaySound") + ": " + e.param1;
                break;

            case "ATC":
                t = LocRm.GetString("SoundThroughCamera") + ": " + e.param1;
                break;

            case "SW":
                t = LocRm.GetString("ShowWindow");
                break;

            case "B":
                t = LocRm.GetString("Beep");
                break;

            case "M":
                t = LocRm.GetString("Maximise");
                break;

            case "MO":
                t = LocRm.GetString("SwitchMonitorOn");
                break;

            case "TA":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id = Convert.ToInt32(op[1]);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("TriggerAlertOn") + " " + n;
            }
            break;

            case "SOO":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id = Convert.ToInt32(op[1]);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("SwitchObjectOn") + " " + n;
            }
            break;

            case "SOF":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id;
                int.TryParse(op[1], out id);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("SwitchObjectOff") + " " + n;
            }
            break;

            case "E":
                t = LocRm.GetString("SendEmail") + ": " + e.param1;
                if (e.param2 != "")
                {
                    bool.TryParse(e.param2, out b);
                    if (b)
                    {
                        t += " (include grab)";
                    }
                }

                break;

            case "SMS":
                t = LocRm.GetString("SendSMS") + ": " + e.param1;
                break;

            case "TM":
                t = LocRm.GetString("SendTwitterMessage");
                break;
            }

            return(t);
        }
Example #20
0
 private void RenderResources()
 {
     _btnOk.Text = LocRm.GetString("Ok");
 }
Example #21
0
        private void Next()
        {
            if (pnlConfig.Visible)
            {
                MainForm.IPLISTED = tbl1.Enabled;
                MainForm.IPRTSP   = chkRTSP.Checked;
                MainForm.IPHTTP   = chkHTTP.Checked;
                if (MainForm.IPLISTED)
                {
                    if (ddlMake.SelectedIndex == -1)
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseMake"));
                        return;
                    }
                }
                else
                {
                    if (!MainForm.IPRTSP && !MainForm.IPHTTP)
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseOption"));
                        return;
                    }
                }
                ShowPanel(pnlLogin);
                return;
            }
            if (pnlLogin.Visible)
            {
                ShowPanel(pnlFindNetwork);
                return;
            }
            if (pnlFindNetwork.Visible)
            {
                string addr = txtIPAddress.Text.Trim();
                if (String.IsNullOrEmpty(addr))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPAddress"));
                    return;
                }
                Uri nUrl = null;
                if (!Uri.TryCreate("http://" + addr, UriKind.Absolute, out nUrl))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPDNSOnly"));
                    return;
                }

                AddConnections();
                return;
            }
            if (pnlConnect.Visible)
            {
                if (MainForm.IPLISTED && ddlMake.SelectedIndex == 0)
                {
                    ShowPanel(pnlConfig);
                    return;
                }

                string make  = txtMake.Text;
                string model = txtModel.Text;

                if (MainForm.IPLISTED)
                {
                    make = ddlMake.SelectedItem.ToString();
                    if (ddlModel.SelectedIndex > 0)
                    {
                        model = ddlModel.SelectedItem.ToString().ToUpper();
                    }
                }


                ManufacturersManufacturerUrl s = null;
                for (int j = 0; j < pnlOptions.Controls.Count; j++)
                {
                    if (pnlOptions.Controls[j] is RadioButton)
                    {
                        if (((RadioButton)pnlOptions.Controls[j]).Checked)
                        {
                            s = (ManufacturersManufacturerUrl)(pnlOptions.Controls[j]).Tag;
                            break;
                        }
                    }
                }
                if (s == null)
                {
                    MessageBox.Show(this, LocRm.GetString("SelectURL"));
                    return;
                }

                FinalUrl = GetAddr(s);

                string source = s.Source;
                if (source == "VLC" && !_vlc)
                {
                    source = "FFMPEG";
                }

                switch (source)
                {
                case "JPEG":
                    VideoSourceType = 0;
                    break;

                case "MJPEG":
                    VideoSourceType = 1;
                    break;

                case "FFMPEG":
                    VideoSourceType = 2;
                    break;

                case "VLC":
                    VideoSourceType = 5;
                    break;
                }

                Ptzid = -1;

                if (!s.@fixed)
                {
                    string modellc = model.ToLower();
                    string n       = make.ToLower();
                    bool   quit    = false;
                    foreach (var ptz in MainForm.PTZs)
                    {
                        int j = 0;
                        foreach (var m in ptz.Makes)
                        {
                            if (m.Name.ToLower() == n)
                            {
                                Ptzid      = ptz.id;
                                Ptzentryid = j;
                                string mdl = m.Model.ToLower();
                                if (mdl == modellc || s.version.ToLower() == mdl)
                                {
                                    Ptzid      = ptz.id;
                                    Ptzentryid = j;
                                    quit       = true;
                                    break;
                                }
                            }
                            j++;
                        }
                        if (quit)
                        {
                            break;
                        }
                    }
                }

                MainForm.IPUN      = txtUsername.Text;
                MainForm.IPPASS    = txtPassword.Text;
                MainForm.IPTYPE    = make;
                MainForm.IPMODEL   = model;
                MainForm.IPADDR    = txtIPAddress.Text;
                MainForm.IPPORTS   = txtPorts.Text;
                MainForm.IPPORT    = (int)numPort.Value;
                MainForm.IPCHANNEL = txtChannel.Text.Trim();

                AudioModel = s.AudioModel;

                LastConfig.PromptSave = !MainForm.IPLISTED && MainForm.IPMODEL.Trim() != "";

                LastConfig.Iptype  = MainForm.IPTYPE;
                LastConfig.Ipmodel = MainForm.IPMODEL;
                LastConfig.Prefix  = s.prefix;
                LastConfig.Source  = s.Source;
                LastConfig.URL     = s.url;
                LastConfig.Cookies = s.cookies;
                LastConfig.Flags   = s.flags;
                if (!String.IsNullOrEmpty(s.port))
                {
                    LastConfig.Port = Convert.ToInt32(s.port);
                }

                if (_dt != null)
                {
                    MainForm.IPTABLE = _dt.Copy();
                }
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Example #22
0
        private void WebservicesLoad(object sender, EventArgs e)
        {
            txtWANPort.Value   = MainForm.Conf.ServerPort;
            txtUsername.Text   = MainForm.Conf.WSUsername;
            txtPassword.Text   = MainForm.Conf.WSPassword;
            txtLANPort.Text    = MainForm.Conf.LANPort.ToString();
            txtPort.Text       = MainForm.Conf.LANPort.ToString();
            chkReroute.Checked = MainForm.Conf.DHCPReroute;

            chkuPNP.Checked = MainForm.Conf.UseUPNP;
            if (!chkuPNP.Checked)
            {
                chkReroute.Checked = chkReroute.Enabled = false;
            }

            lblIPAddresses.Text = LocRm.GetString("PublicIPAddress").Replace("[IP]", MainForm.IPAddressExternal);
            int i2 = 0;

            foreach (IPAddress ipadd in MainForm.AddressListIPv4)
            {
                lbIPv4Address.Items.Add(ipadd.ToString());
                if (ipadd.ToString() == MainForm.AddressIPv4)
                {
                    lbIPv4Address.SelectedIndex = i2;
                }
                i2++;
            }
            if (lbIPv4Address.Items.Count > 0 && lbIPv4Address.SelectedIndex == -1)
            {
                lbIPv4Address.SelectedIndex = 0;
            }

            int _i = 0;

            foreach (IPAddress _ipadd in MainForm.AddressListIPv6)
            {
                lbIPv6Address.Items.Add(_ipadd.ToString());
                if (_ipadd.ToString() == MainForm.AddressIPv6)
                {
                    lbIPv6Address.SelectedIndex = _i;
                }

                _i++;
            }

            if (_i == 0)
            {
                tcIPMode.TabPages.RemoveAt(1);
            }


            if (tcIPMode.TabPages.Count == 2)
            {
                switch (MainForm.Conf.IPMode)
                {
                case "IPv4":
                    tcIPMode.SelectedIndex = 0;
                    break;

                case "IPv6":
                    tcIPMode.SelectedIndex = 1;
                    break;
                }
            }
            else
            {
                tcIPMode.SelectedIndex = 0;
                MainForm.Conf.IPMode   = "IPv4";
            }
            EnableNext();
        }
Example #23
0
        private void Finish()
        {
            int sourceIndex = GetSourceIndex();

            switch (sourceIndex)
            {
            case 0:
                if (!ddlDevice.Enabled)
                {
                    Close();
                    return;
                }
                Mic.settings.sourcename = ddlDevice.SelectedItem.ToString();

                int i = 0, selind = -1;
                for (int n = 0; n < WaveIn.DeviceCount; n++)
                {
                    ddlDevice.Items.Add(WaveIn.GetCapabilities(n).ProductName);
                    if (WaveIn.GetCapabilities(n).ProductName == Mic.settings.sourcename)
                    {
                        selind = i;
                    }
                    i++;
                }

                int channels = WaveIn.GetCapabilities(selind).Channels;

                Mic.settings.channels = channels;
                Mic.settings.samples  = Convert.ToInt32(ddlSampleRate.SelectedItem);
                Mic.settings.bits     = 16;

                break;

            case 1:
                try
                {
                    var url = new Uri(txtNetwork.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                Mic.settings.sourcename = txtNetwork.Text;

                //set format
                Mic.settings.channels = 1;
                Mic.settings.samples  = 22050;
                Mic.settings.bits     = 16;
                break;

            case 2:
            {
                string t = cmbVLCURL.Text.Trim();
                if (t == String.Empty)
                {
                    MessageBox.Show(LocRm.GetString("Validate_Microphone_SelectSource"), LocRm.GetString("Error"));
                    return;
                }
                Mic.settings.sourcename = t;
            }
            break;

            case 3:
                try
                {
                    var url = new Uri(cmbFFMPEGURL.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                Mic.settings.sourcename = cmbFFMPEGURL.Text;
                break;

            case 5:
                if (ddlCloneMicrophone.SelectedIndex > -1)
                {
                    int micid = ((MainForm.ListItem2)ddlCloneMicrophone.SelectedItem).Value;
                    Mic.settings.sourcename = micid.ToString(CultureInfo.InvariantCulture);
                    var mic = MainForm.Microphones.First(p => p.id == micid);
                    Mic.name = "Clone: " + mic.name;
                }
                else
                {
                    MessageBox.Show(this, LocRm.GetString("SelectMicrophoneToClone"));
                    return;
                }
                break;
            }

            MainForm.Conf.VLCURL = cmbVLCURL.Text.Trim();
            if (!MainForm.Conf.RecentVLCList.Contains(MainForm.Conf.VLCURL) &&
                MainForm.Conf.VLCURL != "")
            {
                MainForm.Conf.RecentVLCList =
                    (MainForm.Conf.RecentVLCList + "|" + MainForm.Conf.VLCURL).Trim('|');
            }

            Mic.settings.typeindex  = sourceIndex;
            Mic.settings.decompress = true; // chkDecompress.Checked;
            Mic.settings.vlcargs    = txtVLCArgs.Text.Trim();

            Mic.settings.analyzeduration = (int)numAnalyseDuration.Value;

            DialogResult = DialogResult.OK;
            Close();
        }
Example #24
0
        private void Button1Click(object sender, EventArgs e)
        {
            bool   bIPv6 = tcIPMode.SelectedIndex == 1;
            int    port, localPort;
            string error = "";

            if (!SetupNetwork(out port, out localPort, out error))
            {
                MessageBox.Show(error + " - Try a different port.");
                return;
            }

            if (txtUsername.Text.Trim() != "")
            {
                try
                {
                    var fw = new WinXPSP2FireWall();
                    fw.Initialize();

                    bool bOn = false;
                    fw.IsWindowsFirewallOn(ref bOn);
                    if (bOn)
                    {
                        string strApplication = Application.StartupPath + "\\iSpy.exe";
                        bool   bEnabled       = false;
                        fw.IsAppEnabled(strApplication, ref bEnabled);
                        if (!bEnabled)
                        {
                            fw.AddApplication(strApplication, "iSpy");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MainForm.LogExceptionToFile(ex);
                }

                Next.Enabled = false;
                Next.Text    = "...";
                Application.DoEvents();

                MainForm.Conf.DHCPReroute = chkReroute.Checked;
                bool failed = false;


                var result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);
                if (result[0] != "OK")
                {
                    MessageBox.Show(result[0], LocRm.GetString("Error"));
                    failed = true;
                }

                if (!failed)
                {
                    if (result[0] == "OK")
                    {
                        EmailAddress                  = result[2];
                        MobileNumber                  = result[4];
                        MainForm.Conf.Reseller        = result[5];
                        MainForm.Conf.ServicesEnabled = true;
                        MainForm.Conf.Subscribed      = Convert.ToBoolean(result[1]);
                        if (result[3] != "")
                        {
                            if (!bIPv6)
                            {
                                //try setting port automatically
                                if (chkuPNP.Checked)
                                {
                                    if (!NATControl.SetPorts(port, localPort))
                                    {
                                        MessageBox.Show(LocRm.GetString("ErrorPortMapping"), LocRm.GetString("Error"));
                                        chkuPNP.Checked = false;
                                    }
                                    else
                                    {
                                        result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);
                                    }
                                }
                            }


                            if (result[3] != "")
                            {
                                MainForm.Conf.Loopback = false;
                                Next.Enabled           = true;
                                Next.Text         = LocRm.GetString("Finish");
                                MainForm.LoopBack = false;
                                if (!bIPv6)
                                {
                                    switch (
                                        MessageBox.Show(
                                            LocRm.GetString("ErrorLoopback").Replace("[PORT]", port.ToString()),
                                            LocRm.GetString("Error"), MessageBoxButtons.YesNoCancel))
                                    {
                                    case DialogResult.Yes:
                                        ShowTroubleShooter();
                                        return;

                                    case DialogResult.No:
                                        MainForm.Conf.Loopback = false;
                                        MainForm.LoopBack      = false;
                                        DialogResult           = DialogResult.Yes;
                                        Close();
                                        return;

                                    case DialogResult.Cancel:
                                        return;
                                    }
                                }
                                else
                                {
                                    switch (
                                        MessageBox.Show(
                                            LocRm.GetString("ErrorLoopbackIPv6").Replace("[PORT]", localPort.ToString()),
                                            LocRm.GetString("Error"), MessageBoxButtons.YesNoCancel))
                                    {
                                    case DialogResult.Yes:
                                        ShowTroubleShooter();
                                        return;

                                    case DialogResult.No:
                                        MainForm.Conf.Loopback = false;
                                        MainForm.LoopBack      = false;
                                        DialogResult           = DialogResult.Yes;
                                        Close();
                                        return;

                                    case DialogResult.Cancel:
                                        return;
                                    }
                                }
                            }
                        }
                        if (result[3] == "")
                        {
                            MainForm.Conf.Loopback = true;
                            MainForm.LoopBack      = true;

                            DialogResult = DialogResult.Yes;
                            Close();
                            return;
                        }
                        Next.Enabled = true;
                        Next.Text    = LocRm.GetString("Finish");
                    }
                    else
                    {
                        if (result[0].ToLower().IndexOf("login") == -1)
                        {
                            MessageBox.Show(result[0], LocRm.GetString("Error"));
                        }
                        else
                        {
                            MessageBox.Show(result[0], LocRm.GetString("ConnectFailed"));
                        }
                    }
                }
            }
            else
            {
                Next.Enabled = true;
                Next.Text    = LocRm.GetString("Finish");
                if (
                    MessageBox.Show(LocRm.GetString("WarningLogin"), LocRm.GetString("Note"), MessageBoxButtons.OKCancel) ==
                    DialogResult.Cancel)
                {
                    return;
                }
                MainForm.Conf.ServicesEnabled = false;
                MainForm.Conf.Subscribed      = false;
                MainForm.Conf.WSUsername      = "";
                MainForm.Conf.WSPassword      = "";
                DialogResult = DialogResult.OK;
                Close();
            }
            Next.Enabled = true;
            Next.Text    = LocRm.GetString("Finish");
        }
Example #25
0
        private void Next()
        {
            if (pnlConfig.Visible)
            {
                MainForm.IPLISTED = tbl1.Enabled;
                MainForm.IPRTSP   = chkRTSP.Checked;
                MainForm.IPHTTP   = chkHTTP.Checked;

                if (MainForm.IPLISTED)
                {
                    if (!_hashdata.Contains(txtFindModel.Text.ToUpper()))
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseMake"));
                        return;
                    }
                }
                else
                {
                    if (!MainForm.IPRTSP && !MainForm.IPHTTP)
                    {
                        MessageBox.Show(this, LocRm.GetString("ChooseOption"));
                        return;
                    }
                }
                ShowPanel(pnlLogin);
                return;
            }
            if (pnlLogin.Visible)
            {
                ShowPanel(pnlFindNetwork);
                return;
            }
            if (pnlFindNetwork.Visible)
            {
                string addr = txtIPAddress.Text.Trim();
                if (string.IsNullOrEmpty(addr))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPAddress"));
                    return;
                }
                Uri nUrl = null;
                if (!Uri.TryCreate("http://" + addr, UriKind.Absolute, out nUrl))
                {
                    MessageBox.Show(this, LocRm.GetString("EnterIPDNSOnly"));
                    return;
                }

                AddConnections(nUrl);
                return;
            }
            if (pnlConnect.Visible)
            {
                if (MainForm.IPLISTED && txtFindModel.Text == "")
                {
                    ShowPanel(pnlConfig);
                    return;
                }

                DeviceScanner.Stop();
                string make  = txtMake.Text;
                string model = txtModel.Text;
                FinalUrl = "";
                Username = DeviceScanner.Username;
                Password = DeviceScanner.Password;

                if (MainForm.IPLISTED)
                {
                    var mm = txtFindModel.Text.Split(':');

                    make  = mm[0].Trim();
                    model = "";
                    if (mm.Length > 1)
                    {
                        model = mm[1].Trim().ToUpper();
                    }
                }


                ConnectionOption s = null;
                for (int j = 0; j < pnlOptions.Controls.Count; j++)
                {
                    if (pnlOptions.Controls[j] is RadioButton)
                    {
                        if (((RadioButton)pnlOptions.Controls[j]).Checked)
                        {
                            var o = (pnlOptions.Controls[j]).Tag;
                            s = o as ConnectionOption;
                            if (s == null)
                            {
                                continue;
                            }
                            FinalUrl = s.URL;

                            VideoSourceType = s.VideoSourceTypeID;
                            AudioSourceType = s.AudioSourceTypeID;

                            Ptzid = -1;

                            if (s.MmUrl != null && !s.MmUrl.@fixed)
                            {
                                string modellc = model.ToLower();
                                string n       = make.ToLower();
                                bool   quit    = false;
                                foreach (var ptz in MainForm.PTZs)
                                {
                                    int k = 0;
                                    foreach (var m in ptz.Makes)
                                    {
                                        if (m.Name.ToLower() == n)
                                        {
                                            Ptzid      = ptz.id;
                                            Ptzentryid = k;
                                            string mdl = m.Model.ToLower();
                                            if (mdl == modellc || s.MmUrl.version.ToLower() == mdl)
                                            {
                                                Ptzid      = ptz.id;
                                                Ptzentryid = k;
                                                quit       = true;
                                                break;
                                            }
                                        }
                                        k++;
                                    }
                                    if (quit)
                                    {
                                        break;
                                    }
                                }
                            }

                            break;
                        }
                    }
                }

                if (string.IsNullOrEmpty(FinalUrl))
                {
                    MessageBox.Show(this, LocRm.GetString("SelectURL"));
                    return;
                }


                MainForm.IPUN      = txtUsername.Text;
                MainForm.IPPASS    = txtPassword.Text;
                MainForm.IPTYPE    = make;
                MainForm.IPMODEL   = model;
                MainForm.IPADDR    = txtIPAddress.Text;
                MainForm.IPPORTS   = txtPorts.Text;
                MainForm.IPPORT    = (int)numPort.Value;
                MainForm.IPCHANNEL = txtChannel.Text.Trim();


                LastConfig.PromptSave = !MainForm.IPLISTED && MainForm.IPMODEL.Trim() != "" && VideoSourceType != 9;

                LastConfig.Iptype  = MainForm.IPTYPE;
                LastConfig.Ipmodel = MainForm.IPMODEL;
                if (s?.MmUrl != null)
                {
                    AudioModel         = s.MmUrl.AudioModel;
                    LastConfig.Prefix  = s.MmUrl.prefix;
                    LastConfig.Source  = s.Source;
                    LastConfig.URL     = s.MmUrl.url;
                    LastConfig.Cookies = s.MmUrl.cookies;
                    LastConfig.Flags   = s.MmUrl.flags;

                    tokenPath = s.MmUrl.tokenPath;
                    tokenPost = s.MmUrl.tokenPost;
                    tokenPort = s.MmUrl.tokenPort;


                    if (s.MmUrl.portSpecified)
                    {
                        LastConfig.Port = Convert.ToInt32(s.MmUrl.port);
                    }
                }
                if (_dt != null)
                {
                    MainForm.IPTABLE = _dt.Copy();
                }
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Example #26
0
 private void RenderResources()
 {
     label48.Text = LocRm.GetString("Seconds");
     button1.Text = LocRm.GetString("OK");
 }
Example #27
0
        private void RenderResources()
        {
            btnBack.Text         = LocRm.GetString("Back");
            btnFinish.Text       = LocRm.GetString("Finish");
            btnNext.Text         = LocRm.GetString("Next");
            btnSelectSource.Text = "...";
            chkActive.Text       = LocRm.GetString("MicrophoneActive");
            groupBox1.Text       = LocRm.GetString("RecordingSettings");
            groupBox6.Text       = LocRm.GetString("RecordingSettings");
            groupBox6.Text       = LocRm.GetString("RecordingMode");
            rdoRecordDetect.Text = LocRm.GetString("RecordOnSoundDetection");
            rdoRecordAlert.Text  = LocRm.GetString("RecordOnAlert");
            rdoNoRecord.Text     = LocRm.GetString("NoRecord");
            chkSchedule.Text     = LocRm.GetString("ScheduleMicrophone");
            chkSound.Text        = LocRm.GetString("AlertsEnabled");
            label1.Text          = LocRm.GetString("Name");
            label12.Text         = LocRm.GetString("MaxRecordTime");
            label6.Text          = LocRm.GetString("MinRecordTime");
            label13.Text         = LocRm.GetString("Seconds");
            label14.Text         = LocRm.GetString("Seconds");
            label15.Text         = LocRm.GetString("DistinctAlertInterval");
            label16.Text         = LocRm.GetString("Seconds");
            label17.Text         = LocRm.GetString("Seconds");
            label19.Text         = LocRm.GetString("InactivityRecord");
            label2.Text          = LocRm.GetString("Source");
            label20.Text         = LocRm.GetString("BufferAudio");
            label21.Text         = LocRm.GetString("ExitThisToEnableAlertsAnd");
            label3.Text          = LocRm.GetString("Sensitivity");
            label4.Text          = LocRm.GetString("WhenSound");
            label48.Text         = LocRm.GetString("Seconds");
            label5.Text          = LocRm.GetString("Seconds");
            label15.Text         = LocRm.GetString("Intervals");

            lblAudioSource.Text = LocRm.GetString("Audiosource");
            rdoMovement.Text    = LocRm.GetString("IsDetectedFor");
            rdoNoMovement.Text  = LocRm.GetString("IsNotDetectedFor");
            tabPage1.Text       = LocRm.GetString("Microphone");
            tabPage2.Text       = LocRm.GetString("Alerts");
            tabPage3.Text       = LocRm.GetString("Scheduling");
            tabPage4.Text       = LocRm.GetString("Recording");
            Text = LocRm.GetString("Addmicrophone");

            toolTip1.SetToolTip(txtMicrophoneName, LocRm.GetString("ToolTip_MicrophoneName"));
            toolTip1.SetToolTip(txtInactiveRecord, LocRm.GetString("ToolTip_InactiveRecordAudio"));
            toolTip1.SetToolTip(txtBuffer, LocRm.GetString("ToolTip_BufferAudio"));
            llblHelp.Text        = LocRm.GetString("help");
            lblAccessGroups.Text = LocRm.GetString("AccessGroups");
            toolTip1.SetToolTip(ranger1, LocRm.GetString("ToolTip_MotionSensitivity"));
            label74.Text = LocRm.GetString("Directory");

            LocRm.SetString(label23, "Listen");
            LocRm.SetString(label22, "TriggerRecording");

            label11.Text = LocRm.GetString("MediaLocation");
            label74.Text = LocRm.GetString("Directory");
            chkStorageManagement.Text = LocRm.GetString("EnableStorageManagement");
            label85.Text    = LocRm.GetString("MaxFolderSizeMb");
            label94.Text    = LocRm.GetString("MaxAgeHours");
            chkArchive.Text = LocRm.GetString("ArchiveInsteadOfDelete");
            btnRunNow.Text  = LocRm.GetString("RunNow");

            HideTab(tabPage2, Helper.HasFeature(Enums.Features.Alerts));
            HideTab(tabPage4, Helper.HasFeature(Enums.Features.Recording));
            HideTab(tabPage3, Helper.HasFeature(Enums.Features.Scheduling));
            HideTab(tabPage5, Helper.HasFeature(Enums.Features.Storage));
            LocRm.SetString(linkLabel4, "CopyTo");
        }
Example #28
0
 private void btnCenterAxes_Click(object sender, EventArgs e)
 {
     CenterAxes();
     MessageBox.Show(this, LocRm.GetString("AxesCentered"));
 }
Example #29
0
        private void AddMicrophoneLoad(object sender, EventArgs e)
        {
            if (VolumeLevel.Micobject.id == -1)
            {
                if (!SelectSource())
                {
                    Close();
                    return;
                }
            }
            if (VolumeLevel.Micobject.id == -1)
            {
                VolumeLevel.Micobject.id = MainForm.NextMicrophoneId;
            }
            VolumeLevel.IsEdit = true;
            if (VolumeLevel.CameraControl != null)
            {
                VolumeLevel.CameraControl.IsEdit = true;
            }

            btnBack.Enabled        = false;
            txtMicrophoneName.Text = VolumeLevel.Micobject.name;
            //tbGain.Value = (int)(VolumeLevel.Micobject.settings.gain * 100);

            chkSound.Checked        = VolumeLevel.Micobject.alerts.active;
            rdoRecordDetect.Checked = VolumeLevel.Micobject.detector.recordondetect;
            rdoRecordAlert.Checked  = VolumeLevel.Micobject.detector.recordonalert;
            rdoNoRecord.Checked     = !rdoRecordDetect.Checked && !rdoRecordAlert.Checked;

            if (VolumeLevel.Micobject.alerts.mode == "sound")
            {
                rdoMovement.Checked = true;
            }
            else
            {
                rdoNoMovement.Checked = true;
            }

            chkSchedule.Checked = VolumeLevel.Micobject.schedule.active;
            chkActive.Checked   = VolumeLevel.Micobject.settings.active;

            chkActive.Enabled = VolumeLevel.Micobject.settings.sourcename != "";

            if (VolumeLevel.Micobject.settings.sourcename != "")
            {
                lblAudioSource.Text = "";
                if (VolumeLevel.Micobject.settings.typeindex == 4)
                {
                    int icam;
                    if (Int32.TryParse(VolumeLevel.Micobject.settings.sourcename, out icam))
                    {
                        var c = MainForm.Cameras.SingleOrDefault(p => p.id == icam);
                        if (c != null)
                        {
                            lblAudioSource.Text = c.name;
                        }
                    }
                }
                if (lblAudioSource.Text == "")
                {
                    lblAudioSource.Text = VolumeLevel.Micobject.settings.sourcename;
                }
            }
            else
            {
                lblAudioSource.Text = LocRm.GetString("NoSource");
                chkActive.Checked   = false;
            }



            Text = LocRm.GetString("EditMicrophone");
            if (VolumeLevel.Micobject.id > -1)
            {
                Text += string.Format(" (ID: {0}, DIR: {1})", VolumeLevel.Micobject.id, VolumeLevel.Micobject.directory);
            }

            txtNoSound.Text  = VolumeLevel.Micobject.detector.nosoundinterval.ToString(CultureInfo.InvariantCulture);
            txtSound.Text    = VolumeLevel.Micobject.detector.soundinterval.ToString(CultureInfo.InvariantCulture);
            pnlSound.Enabled = chkSound.Checked;

            txtBuffer.Text         = VolumeLevel.Micobject.settings.buffer.ToString(CultureInfo.InvariantCulture);
            txtInactiveRecord.Text = VolumeLevel.Micobject.recorder.inactiverecord.ToString(CultureInfo.InvariantCulture);
            txtMaxRecordTime.Text  = VolumeLevel.Micobject.recorder.maxrecordtime.ToString(CultureInfo.InvariantCulture);

            scheduleEditor1.Io = VolumeLevel;

            txtAccessGroups.Text = VolumeLevel.Micobject.settings.accessgroups;
            txtDirectory.Text    = VolumeLevel.Micobject.directory;


            tblStorage.Enabled     = chkStorageManagement.Checked = VolumeLevel.Micobject.settings.storagemanagement.enabled;
            numMaxAge.Value        = VolumeLevel.Micobject.settings.storagemanagement.maxage;
            numMaxFolderSize.Value = VolumeLevel.Micobject.settings.storagemanagement.maxsize;
            numMinRecord.Value     = VolumeLevel.Micobject.recorder.minrecordtime;

            ddlCopyFrom.Items.Clear();
            ddlCopyFrom.Items.Add(new ListItem(LocRm.GetString("CopyFrom"), "-1"));
            foreach (objectsMicrophone c in MainForm.Microphones)
            {
                if (c.id != VolumeLevel.Micobject.id)
                {
                    ddlCopyFrom.Items.Add(new ListItem(c.name, c.id.ToString(CultureInfo.InvariantCulture)));
                }
            }
            ddlCopyFrom.SelectedIndex = 0;


            int i = 0, j = 0;

            foreach (var dev in DirectSoundOut.Devices)
            {
                ddlPlayback.Items.Add(new ListItem(dev.Description, dev.Guid.ToString()));
                if (dev.Guid.ToString() == VolumeLevel.Micobject.settings.deviceout)
                {
                    i = j;
                }
                j++;
            }
            if (ddlPlayback.Items.Count > 0)
            {
                ddlPlayback.SelectedIndex = i;
            }
            else
            {
                ddlPlayback.Items.Add(LocRm.GetString("NoAudioDevices"));
                ddlPlayback.Enabled = false;
            }

            tmrUpdateSourceDetails.Start();

            foreach (string dt in _actiontypes)
            {
                ddlActionType.Items.Add(LocRm.GetString(dt));
            }
            ddlActionType.SelectedIndex = 0;

            string t2 = VolumeLevel.Micobject.recorder.trigger ?? "";


            ddlTriggerRecording.Items.Add(new ListItem("None", ""));

            foreach (var c in MainForm.Cameras.Where(p => p.settings.micpair != VolumeLevel.Micobject.id))
            {
                ddlTriggerRecording.Items.Add(new ListItem(c.name, "2," + c.id));
            }
            foreach (var c in MainForm.Microphones.Where(p => p.id != VolumeLevel.Micobject.id))
            {
                ddlTriggerRecording.Items.Add(new ListItem(c.name, "1," + c.id));
            }
            foreach (ListItem li in ddlTriggerRecording.Items)
            {
                if (li.Value == t2)
                {
                    ddlTriggerRecording.SelectedItem = li;
                }
            }

            if (ddlTriggerRecording.SelectedIndex == -1)
            {
                ddlTriggerRecording.SelectedIndex = 0;
            }

            if (VolumeLevel.CameraControl != null)
            {
                txtBuffer.Enabled = false;
                toolTip1.SetToolTip(txtBuffer, "Change the buffer on the paired camera to update");
            }

            actionEditor1.LoginRequested += ActionEditor1LoginRequested;
            chkArchive.Checked            = VolumeLevel.Micobject.settings.storagemanagement.archive;

            LoadMediaDirectories();

            ranger1.Maximum          = 100;
            ranger1.Minimum          = 0.001;
            ranger1.ValueMin         = VolumeLevel.Micobject.detector.minsensitivity;
            ranger1.ValueMax         = VolumeLevel.Micobject.detector.maxsensitivity;
            ranger1.Gain             = VolumeLevel.Micobject.detector.gain;
            ranger1.ValueMinChanged += Ranger1ValueMinChanged;
            ranger1.ValueMaxChanged += Ranger1ValueMaxChanged;
            ranger1.GainChanged     += Ranger1GainChanged;
            ranger1.SetText();

            intervalConfig1.Init(VolumeLevel);

            chkMessaging.Checked = VolumeLevel.Micobject.settings.messaging;
            _loaded = true;
        }
Example #30
0
        private void Button1Click(object sender, EventArgs e)
        {
            bool   bIPv6 = tcIPMode.SelectedIndex == 1;
            int    port, localPort;
            string error;

            if (!SetupNetwork(out port, out localPort, out error))
            {
                MessageBox.Show(error + Environment.NewLine + LocRm.GetString("TryDifferentPort"));
                return;
            }

            if (!string.IsNullOrWhiteSpace(txtUsername.Text.Trim()))
            {
                try
                {
                    var fw = new FireWall();
                    var r  = fw.Initialize();
                    if (r == FireWall.FwErrorCode.FwNoerror)
                    {
                        bool bOn;
                        r = fw.IsWindowsFirewallOn(out bOn);
                        if (r == FireWall.FwErrorCode.FwNoerror)
                        {
                            if (bOn)
                            {
                                string strApplication = Application.StartupPath + "\\iSpy.exe";
                                bool   bEnabled       = false;
                                r = fw.IsAppEnabled(strApplication, ref bEnabled);
                                if (r == FireWall.FwErrorCode.FwNoerror)
                                {
                                    if (!bEnabled)
                                    {
                                        fw.AddApplication(strApplication, "iSpy");
                                    }
                                }
                            }
                        }
                    }
                    if (r != FireWall.FwErrorCode.FwNoerror)
                    {
                        throw new Exception(r.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    MessageBox.Show(this,
                                    LocRm.GetString("ErrorFromFirewall") + Environment.NewLine + ex.Message + Environment.NewLine +
                                    LocRm.GetString("AddFirewallExceptionManually"));
                }

                Next.Enabled = false;
                Next.Text    = "...";
                Application.DoEvents();

                MainForm.Conf.DHCPReroute = chkReroute.Checked;
                MainForm.Conf.SpecificIP  = chkBindSpecific.Checked;

                bool failed = false;


                var result = new string[] { "OK" }; // WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);
                if (result[0] != "OK")
                {
                    MessageBox.Show(result[0], LocRm.GetString("Error"));
                    failed = true;
                }

                if (!failed)
                {
                    if (result.Length > 0 && result[0] == "OK")
                    {
                        EmailAddress                  = result[2];
                        MobileNumber                  = result[4];
                        MainForm.Conf.Reseller        = result[5];
                        MainForm.Conf.ServicesEnabled = true;
                        MainForm.Conf.Subscribed      = Convert.ToBoolean(result[1]);
                        if (result[3] != "")
                        {
                            if (!bIPv6)
                            {
                                //try setting port automatically
                                if (chkuPNP.Checked)
                                {
                                    if (!NATControl.SetPorts(port, localPort))
                                    {
                                        MessageBox.Show(LocRm.GetString("ErrorPortMapping"), LocRm.GetString("Error"));
                                        chkuPNP.Checked = false;
                                    }
                                    else
                                    {
                                        //converted to noop result = WsWrapper.TestConnection(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, true);
                                    }
                                }
                            }

                            if (result[3] != "")
                            {
                                MainForm.Conf.Loopback = false;
                                Next.Enabled           = true;
                                Next.Text         = LocRm.GetString("Finish");
                                MainForm.LoopBack = false;
                                if (!bIPv6)
                                {
                                    switch (
                                        MessageBox.Show(
                                            LocRm.GetString("ErrorLoopback").Replace("[PORT]", port.ToString(CultureInfo.InvariantCulture)),
                                            LocRm.GetString("Error"), MessageBoxButtons.YesNoCancel))
                                    {
                                    case DialogResult.Yes:
                                        ShowTroubleShooter();
                                        return;

                                    case DialogResult.No:
                                        MainForm.Conf.Loopback = false;
                                        MainForm.LoopBack      = false;
                                        DialogResult           = DialogResult.Yes;
                                        Close();
                                        return;

                                    case DialogResult.Cancel:
                                        return;
                                    }
                                }
                                else
                                {
                                    switch (
                                        MessageBox.Show(
                                            LocRm.GetString("ErrorLoopbackIPv6").Replace("[PORT]", localPort.ToString(CultureInfo.InvariantCulture)),
                                            LocRm.GetString("Error"), MessageBoxButtons.YesNoCancel))
                                    {
                                    case DialogResult.Yes:
                                        ShowTroubleShooter();
                                        return;

                                    case DialogResult.No:
                                        MainForm.Conf.Loopback = false;
                                        MainForm.LoopBack      = false;
                                        DialogResult           = DialogResult.Yes;
                                        Close();
                                        return;

                                    case DialogResult.Cancel:
                                        return;
                                    }
                                }
                            }
                        }
                        if (result[3] == "")
                        {
                            MainForm.Conf.Loopback = true;
                            MainForm.LoopBack      = true;

                            DialogResult = DialogResult.Yes;
                            Close();
                            return;
                        }
                        Next.Enabled = true;
                        Next.Text    = LocRm.GetString("Finish");
                    }
                    else
                    {
                        if (result.Length > 0 && result[0].ToLower().IndexOf("login", StringComparison.Ordinal) == -1)
                        {
                            MessageBox.Show(result[0], LocRm.GetString("Error"));
                        }
                        else
                        {
                            MessageBox.Show(LocRm.GetString("NoResponse"), LocRm.GetString("ConnectFailed"));
                        }
                    }
                }
            }
            else
            {
                Next.Enabled = true;
                Next.Text    = LocRm.GetString("Finish");
                if (
                    MessageBox.Show(LocRm.GetString("WarningLogin"), LocRm.GetString("Note"), MessageBoxButtons.OKCancel) ==
                    DialogResult.Cancel)
                {
                    return;
                }
                MainForm.Conf.ServicesEnabled = false;
                MainForm.Conf.Subscribed      = false;
                MainForm.Conf.WSUsername      = "";
                MainForm.Conf.WSPassword      = "";
                DialogResult = DialogResult.OK;
                Close();
            }
            Next.Enabled = true;
            Next.Text    = LocRm.GetString("Finish");
        }