コード例 #1
0
ファイル: MainForm.cs プロジェクト: vmail/main
 private void WebConnect()
 {
     var ws = new WebservicesForm();
     ws.ShowDialog(this);
     if (ws.EmailAddress != "")
     {
         EmailAddress = ws.EmailAddress;
         MobileNumber = ws.MobileNumber;
     }
     if (ws.DialogResult == DialogResult.Yes)
     {
         Connect(false);
     }
     ws.Dispose();
     Text = string.Format("iSpy v{0}", Application.ProductVersion);
     if (Conf.WSUsername != "")
     {
         Text += string.Format(" ({0})", Conf.WSUsername);
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: vmail/main
 public void Connect(string successUrl, bool silent)
 {
     if (!MWS.Running)
     {
         string message = StopAndStartServer();
         if (message != "")
         {
             if (!silent)
                 MessageBox.Show(this, message);
             return;
         }
     }
     if (WsWrapper.WebsiteLive)
     {
         if (Conf.WSUsername != null && Conf.WSUsername.Trim() != "")
         {
             if (Conf.UseUPNP)
             {
                 NATControl.SetPorts(Conf.ServerPort, Conf.LANPort);
             }
             WsWrapper.Connect();
             WsWrapper.ForceSync();
             if (WsWrapper.WebsiteLive)
             {
                 if (successUrl != "")
                     StartBrowser(successUrl);
                 return;
             }
             if (!silent && !_shuttingDown)
                 Log.Info(LocRm.GetString("WebsiteDown"));
             return;
         }
         var ws = new WebservicesForm();
         ws.ShowDialog(this);
         if (ws.EmailAddress != "")
             EmailAddress = ws.EmailAddress;
         if (ws.DialogResult == DialogResult.Yes || ws.DialogResult == DialogResult.No)
         {
             ws.Dispose();
             Connect(successUrl, silent);
             return;
         }
         ws.Dispose();
     }
     else
     {
         Log.Info(LocRm.GetString("WebsiteDown"));
     }
 }
コード例 #3
0
ファイル: AddCameraForm.cs プロジェクト: vmail/main
        private void Finish()
        {
            //validate page 0
            if (CheckStep1())
            {
                string err = "";
                if (chkSendSMSMovement.Checked && MainForm.Conf.ServicesEnabled &&
                    txtSMSNumber.Text.Trim() == "")
                    err += LocRm.GetString("Validate_Camera_MobileNumber") + Environment.NewLine;

                string[] smss = txtSMSNumber.Text.Trim().Replace(" ", "").Split(';');
                string sms = "";
                foreach (string s in smss)
                {
                    string sms2 = s.Trim();
                    if (!String.IsNullOrEmpty(sms))
                    {
                        if (sms2.StartsWith("00"))
                            sms2 = sms2.Substring(2);
                        if (sms2.StartsWith("+"))
                            sms2 = sms2.Substring(1);
                        if (sms2 != "")
                        {
                            sms += sms2 + ";";
                            if (!IsNumeric(sms2))
                            {
                        err += LocRm.GetString("Validate_Camera_SMSNumbers") + Environment.NewLine;
                                break;
                }

                        }
                    }
                }
                sms = sms.Trim(';');

                string email = txtEmailAlert.Text.Replace(" ", "");
                if (email != "" && !email.IsValidEmail())
                {
                    err += LocRm.GetString("Validate_Camera_EmailAlerts") + Environment.NewLine;
                }

                if (email == "")
                {
                    chkSendEmailMovement.Checked = false;
                    chkEmailOnDisconnect.Checked = false;
                }
                if (sms == "")
                {
                    chkSendSMSMovement.Checked = false;
                    chkMMS.Checked = false;
                }

                if (txtBuffer.Text.Length < 1 || txtInactiveRecord.Text.Length < 1 ||
                    txtCalibrationDelay.Text.Length < 1 || txtMaxRecordTime.Text.Length < 1)
                {
                    err += LocRm.GetString("Validate_Camera_RecordingSettings") + Environment.NewLine;
                }
                if (err != "")
                {
                    MessageBox.Show(err, LocRm.GetString("Error"));
                    return;
                }

                if (chkFTP.Checked)
                {
                    try
                    {
                        var request = (FtpWebRequest) WebRequest.Create(txtFTPServer.Text);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(LocRm.GetString("Validate_Camera_CheckFTP"));
                        return;
                    }
                }

                if (chkSendEmailMovement.Checked)
                {
                    if (MainForm.Conf.WSUsername == "")
                    {
                        if (MessageBox.Show(
                            LocRm.GetString("Validate_Camera_Login"), LocRm.GetString("Note"), MessageBoxButtons.YesNo) ==
                            DialogResult.Yes)
                        {
                            var ws = new WebservicesForm();
                            ws.ShowDialog(this);
                            if (ws.DialogResult != DialogResult.Yes)
                            {
                                chkSendEmailMovement.Checked = false;
                                chkMMS.Checked = false;
                                chkEmailOnDisconnect.Checked = false;
                                chkSendSMSMovement.Checked = false;
                            }
                            ws.Dispose();
                        }
                    }
                }
                int ftpport;
                if (!int.TryParse(txtFTPPort.Text, out ftpport))
                {
                    MessageBox.Show(LocRm.GetString("Validate_Camera_FTPPort"));
                    return;
                }
                int ftpinterval;
                if (!int.TryParse(txtUploadEvery.Text, out ftpinterval))
                {
                    MessageBox.Show(LocRm.GetString("Validate_Camera_FTPInterval"));
                    return;
                }

                int timelapseframes;
                if (!int.TryParse(txtTimeLapseFrames.Text, out timelapseframes))
                {
                    MessageBox.Show(LocRm.GetString("Validate_Camera_TimelapseInterval"));
                    return;
                }

                int timelapsemovie;

                if (!int.TryParse(txtTimeLapse.Text, out timelapsemovie))
                {
                    MessageBox.Show(LocRm.GetString("Validate_Camera_TimelapseBuffer"));
                    return;
                }
                string localFilename=txtLocalFilename.Text.Trim();
                if (localFilename.IndexOf("\\", System.StringComparison.Ordinal)!=-1)
                {
                    MessageBox.Show("Please enter a filename only for local saving (no path information)");
                    return;
                }

                string audioip = txtAudioOutIP.Text.Trim();

                if (!String.IsNullOrEmpty(audioip))
                {
                    IPAddress _aip;
                    if (!IPAddress.TryParse(audioip, out _aip))
                    {
                        try
                        {
                            IPHostEntry ipE = Dns.GetHostEntry(audioip);
                            IPAddress[] ipA = ipE.AddressList;
                            if (ipA==null || ipA.Length == 0)
                            {
                                MessageBox.Show("Enter a valid IP address or domain for talk or clear the field.");
                                return;
                            }
                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show("Enter a valid IP address or domain for talk or clear the field. ("+ex.Message+")");
                            return;
                        }
                    }
                }

                CameraControl.Camobject.detector.processeveryframe =
                    Convert.ToInt32(ddlProcessFrames.SelectedItem.ToString());
                CameraControl.Camobject.detector.motionzones = AreaControl.MotionZones;
                CameraControl.Camobject.detector.type = (string) _detectortypes[ddlMotionDetector.SelectedIndex];
                CameraControl.Camobject.detector.postprocessor = (string) _processortypes[ddlProcessor.SelectedIndex];
                CameraControl.Camobject.name = txtCameraName.Text.Trim();

                //update to plugin if connected and supported
                if (CameraControl.Camera != null && CameraControl.Camera.Plugin != null)
                {
                    try
                    {
                        var plugin = CameraControl.Camera.Plugin;
                        plugin.GetType().GetProperty("CameraName").SetValue(plugin, CameraControl.Camobject.name, null);
                    }
                    catch
                    {
                    }
                }

                CameraControl.Camobject.alerts.active = chkMovement.Checked;
                CameraControl.Camobject.alerts.executefile = txtExecuteMovement.Text;
                CameraControl.Camobject.alerts.alertoptions = chkBeep.Checked + "," + chkRestore.Checked;
                CameraControl.Camobject.notifications.sendemail = chkSendEmailMovement.Checked;
                CameraControl.Camobject.notifications.sendsms = chkSendSMSMovement.Checked;
                CameraControl.Camobject.notifications.sendmms = chkMMS.Checked;
                CameraControl.Camobject.settings.emailaddress = email;
                CameraControl.Camobject.settings.smsnumber = sms;
                CameraControl.Camobject.settings.notifyondisconnect = chkEmailOnDisconnect.Checked;
                CameraControl.Camobject.settings.ptzautohomedelay = (int)numAutoHomeDelay.Value;
                CameraControl.Camobject.settings.ptzusername = txtPTZUsername.Text;
                CameraControl.Camobject.settings.ptzpassword = txtPTZPassword.Text;
                CameraControl.Camobject.settings.ptzchannel = txtPTZChannel.Text;
                CameraControl.Camobject.ptzschedule.active = chkSchedulePTZ.Checked;
                CameraControl.Camobject.recorder.quality = tbQuality.Value;
                CameraControl.Camobject.recorder.timelapsesave = (int)numTimelapseSave.Value;
                CameraControl.Camobject.recorder.timelapseframerate = (int)numFramerate.Value;
                CameraControl.Camobject.ftp.savelocal = chkLocalSaving.Checked;
                CameraControl.Camobject.ftp.quality = tbFTPQuality.Value;
                CameraControl.Camobject.notifications.sendtwitter = chkTwitter.Checked;
                CameraControl.Camobject.ftp.localfilename = txtLocalFilename.Text.Trim();
                CameraControl.Camobject.alerts.maximise = chkMaximise.Checked;
                CameraControl.Camobject.ptzschedule.suspend = chkSuspendOnMovement.Checked;
                CameraControl.Camobject.alerts.playsound = txtSound.Text;
                CameraControl.Camobject.ftp.countermax = (int) numMaxCounter.Value;

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

                if (CameraControl.Camobject.directory != txtDirectory.Text)
                {
                    string path = MainForm.Conf.MediaDirectory + "video\\" + txtDirectory.Text + "\\";
                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);
                    path = MainForm.Conf.MediaDirectory + "video\\" + txtDirectory.Text + "\\thumbs\\";

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }

                CameraControl.Camobject.directory = txtDirectory.Text;

                CameraControl.Camobject.schedule.active = chkSchedule.Checked;
                CameraControl.Camobject.settings.active = chkActive.Checked;

                int bufferseconds,
                    calibrationdelay,
                    inactiveRecord,
                    minimuminterval,
                    maxrecord;
                int.TryParse(txtBuffer.Text, out bufferseconds);
                int.TryParse(txtCalibrationDelay.Text, out calibrationdelay);
                int.TryParse(txtInactiveRecord.Text, out inactiveRecord);
                int.TryParse(txtMinimumInterval.Text, out minimuminterval);
                int.TryParse(txtMaxRecordTime.Text, out maxrecord);

                CameraControl.Camobject.recorder.bufferseconds = bufferseconds;

                var m = MainForm.Microphones.SingleOrDefault(p => p.id == CameraControl.Camobject.settings.micpair);
                if (m != null)
                    m.settings.buffer = CameraControl.Camobject.recorder.bufferseconds;

                CameraControl.Camobject.detector.calibrationdelay = calibrationdelay;
                CameraControl.Camobject.recorder.inactiverecord = inactiveRecord;
                CameraControl.Camobject.alerts.minimuminterval = minimuminterval;
                CameraControl.Camobject.alerts.processmode = "continuous";
                if (rdoMotion.Checked)
                    CameraControl.Camobject.alerts.processmode = "motion";
                CameraControl.Camobject.recorder.maxrecordtime = maxrecord;
                CameraControl.Camobject.recorder.timelapseenabled = chkTimelapse.Checked;

                CameraControl.Camobject.ftp.enabled = chkFTP.Checked;
                CameraControl.Camobject.ftp.server = txtFTPServer.Text;
                CameraControl.Camobject.ftp.usepassive = chkUsePassive.Checked;
                CameraControl.Camobject.ftp.username = txtFTPUsername.Text;
                CameraControl.Camobject.ftp.password = txtFTPPassword.Text;
                CameraControl.Camobject.ftp.port = ftpport;
                CameraControl.Camobject.ftp.interval = ftpinterval;
                CameraControl.Camobject.ftp.filename = txtFTPFilename.Text;
                CameraControl.Camobject.ftp.text = txtFTPText.Text;
                CameraControl.Camobject.settings.ptzautotrack = chkTrack.Checked;
                CameraControl.Camobject.settings.ptzautohome = chkAutoHome.Checked;
                CameraControl.Camobject.settings.ptzautotrackmode = 0;

                if (rdoVert.Checked)
                    CameraControl.Camobject.settings.ptzautotrackmode = 1;
                if (rdoHor.Checked)
                    CameraControl.Camobject.settings.ptzautotrackmode = 2;

                CameraControl.Camobject.settings.ptztimetohome = Convert.ToInt32(numTTH.Value);

                int ftpmode = 0;
                if (rdoFTPAlerts.Checked)
                    ftpmode = 1;
                if (rdoFTPInterval.Checked)
                    ftpmode = 2;

                CameraControl.Camobject.ftp.mode = ftpmode;

                CameraControl.Camobject.recorder.timelapseframes = timelapseframes;
                CameraControl.Camobject.recorder.timelapse = timelapsemovie;
                CameraControl.Camobject.recorder.profile = ddlProfile.SelectedIndex;

                CameraControl.Camobject.settings.youtube.autoupload = chkUploadYouTube.Checked;
                CameraControl.Camobject.settings.youtube.category = ddlCategory.SelectedItem.ToString();
                [email protected] = chkPublic.Checked;
                CameraControl.Camobject.settings.youtube.tags = txtTags.Text;
                CameraControl.Camobject.settings.maxframeraterecord = (int)numMaxFRRecording.Value;

                CameraControl.Camobject.alerts.arguments = txtArguments.Text;

                CameraControl.Camobject.settings.accessgroups = txtAccessGroups.Text;
                CameraControl.Camobject.detector.recordonalert = rdoRecordAlert.Checked;
                CameraControl.Camobject.detector.recordondetect = rdoRecordDetect.Checked;

                CameraControl.UpdateFloorplans(false);

                CameraControl.Camobject.settings.audiomodel = ddlTalkModel.SelectedItem.ToString();
                CameraControl.Camobject.settings.audioport = (int)numTalkPort.Value;
                CameraControl.Camobject.settings.audioip = txtAudioOutIP.Text.Trim();
                CameraControl.Camobject.settings.audiousername = txtTalkUsername.Text;
                CameraControl.Camobject.settings.audiopassword = txtTalkPassword.Text;

                CameraControl.Camobject.alerts.trigger = ((ListItem) ddlTrigger.SelectedItem).Value;
                CameraControl.Camobject.recorder.trigger = ((ListItem)ddlTriggerRecording.SelectedItem).Value;

                DialogResult = DialogResult.OK;
                MainForm.NeedsSync = true;
                IsNew = false;
                Close();
                return;
            }
            return;
        }