private void AutoType_SequenceQuery(object sender, SequenceQueryEventArgs e)
        {
            if (e.Entry.GetAutoTypeSequence().Contains(PLACEHOLDER))
            {
                DlgPickCustomField picker = new DlgPickCustomField();
                picker.PickCustomField(PLACEHOLDER, e.Entry);

                if (picker.DialogResult == DialogResult.OK && picker.SelectedField != null)
                {
                    this.CurrentPlaceholderResolved = picker.SelectedField.Value;
                    e.Entry.AutoType.DefaultSequence = e.Entry.AutoType.DefaultSequence.Replace(PLACEHOLDER, picker.SelectedField.Value);
                }
            }
        }
Esempio n. 2
0
        private static void RaiseSequenceQueryEvent(
            EventHandler <SequenceQueryEventArgs> f, int iEventID, IntPtr hWnd,
            string strWindow, PwEntry pwe, PwDatabase pdContext,
            List <string> lSeq)
        {
            if (f == null)
            {
                return;
            }

            SequenceQueryEventArgs e = new SequenceQueryEventArgs(iEventID,
                                                                  hWnd, strWindow, pwe, pdContext);

            f(null, e);

            foreach (string strSeq in e.Sequences)
            {
                AddSequence(lSeq, strSeq);
            }
        }
Esempio n. 3
0
        // Multiple calls of this method should be wrapped in
        // GetSequencesForWindowBegin and GetSequencesForWindowEnd
        private static List<string> GetSequencesForWindow(PwEntry pwe,
            IntPtr hWnd, string strWindow, PwDatabase pdContext, int iEventID)
        {
            List<string> l = new List<string>();

            if(pwe == null) { Debug.Assert(false); return l; }
            if(strWindow == null) { Debug.Assert(false); return l; }

            if(!pwe.GetAutoTypeEnabled()) return l;

            SprContext sprCtx = new SprContext(pwe, pdContext,
                SprCompileFlags.NonActive);

            // Specifically defined sequences must match before the title,
            // in order to allow selecting the first item as default one
            foreach(AutoTypeAssociation a in pwe.AutoType.Associations)
            {
                string strWndSpec = a.WindowName;
                if(strWndSpec == null) { Debug.Assert(false); continue; }

                strWndSpec = SprEngine.Compile(strWndSpec.Trim(), sprCtx);

                if(MatchWindows(strWndSpec, strWindow))
                {
                    string strSeq = a.Sequence;
                    if(string.IsNullOrEmpty(strSeq))
                        strSeq = pwe.GetAutoTypeSequence();
                    AddSequence(l, strSeq);
                }
            }

            if(Program.Config.Integration.AutoTypeMatchByTitle)
            {
                string strTitle = SprEngine.Compile(pwe.Strings.ReadSafe(
                    PwDefs.TitleField).Trim(), sprCtx);
                if((strTitle.Length > 0) && (strWindow.IndexOf(strTitle,
                    StrUtil.CaseIgnoreCmp) >= 0))
                    AddSequence(l, pwe.GetAutoTypeSequence());
            }

            string strCmpUrl = null; // To cache compiled URL
            if(Program.Config.Integration.AutoTypeMatchByUrlInTitle)
            {
                strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
                    PwDefs.UrlField).Trim(), sprCtx);
                if((strCmpUrl.Length > 0) && (strWindow.IndexOf(strCmpUrl,
                    StrUtil.CaseIgnoreCmp) >= 0))
                    AddSequence(l, pwe.GetAutoTypeSequence());
            }

            if(Program.Config.Integration.AutoTypeMatchByUrlHostInTitle)
            {
                if(strCmpUrl == null)
                    strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
                        PwDefs.UrlField).Trim(), sprCtx);

                string strCleanUrl = StrUtil.RemovePlaceholders(strCmpUrl);
                string strHost = UrlUtil.GetHost(strCleanUrl);

                if(strHost.StartsWith("www.", StrUtil.CaseIgnoreCmp) &&
                    (strCleanUrl.StartsWith("http:", StrUtil.CaseIgnoreCmp) ||
                    strCleanUrl.StartsWith("https:", StrUtil.CaseIgnoreCmp)))
                    strHost = strHost.Substring(4);

                if((strHost.Length > 0) && (strWindow.IndexOf(strHost,
                    StrUtil.CaseIgnoreCmp) >= 0))
                    AddSequence(l, pwe.GetAutoTypeSequence());
            }

            if(Program.Config.Integration.AutoTypeMatchByTagInTitle)
            {
                foreach(string strTag in pwe.Tags)
                {
                    if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); continue; }

                    if(strWindow.IndexOf(strTag, StrUtil.CaseIgnoreCmp) >= 0)
                    {
                        AddSequence(l, pwe.GetAutoTypeSequence());
                        break;
                    }
                }
            }

            if(AutoType.SequenceQuery != null)
            {
                SequenceQueryEventArgs e = new SequenceQueryEventArgs(iEventID,
                    hWnd, strWindow, pwe, pdContext);
                AutoType.SequenceQuery(null, e);

                foreach(string strSeq in e.Sequences)
                    AddSequence(l, strSeq);
            }

            return l;
        }
Esempio n. 4
0
		private static void RaiseSequenceQueryEvent(
			EventHandler<SequenceQueryEventArgs> f, int iEventID, IntPtr hWnd,
			string strWindow, PwEntry pwe, PwDatabase pdContext,
			List<string> lSeq)
		{
			if(f == null) return;

			SequenceQueryEventArgs e = new SequenceQueryEventArgs(iEventID,
				hWnd, strWindow, pwe, pdContext);
			f(null, e);

			foreach(string strSeq in e.Sequences)
				AddSequence(lSeq, strSeq);
		}
Esempio n. 5
0
        // Multiple calls of this method should be wrapped in
        // GetSequencesForWindowBegin and GetSequencesForWindowEnd
        private static List <string> GetSequencesForWindow(PwEntry pwe,
                                                           IntPtr hWnd, string strWindow, PwDatabase pdContext, int iEventID)
        {
            List <string> l = new List <string>();

            if (pwe == null)
            {
                Debug.Assert(false); return(l);
            }
            if (strWindow == null)
            {
                Debug.Assert(false); return(l);
            }

            if (!pwe.GetAutoTypeEnabled())
            {
                return(l);
            }

            SprContext sprCtx = new SprContext(pwe, pdContext,
                                               SprCompileFlags.NonActive);

            // Specifically defined sequences must match before the title,
            // in order to allow selecting the first item as default one
            foreach (AutoTypeAssociation a in pwe.AutoType.Associations)
            {
                string strWndSpec = a.WindowName;
                if (strWndSpec == null)
                {
                    Debug.Assert(false); continue;
                }

                strWndSpec = SprEngine.Compile(strWndSpec.Trim(), sprCtx);

                if (MatchWindows(strWndSpec, strWindow))
                {
                    string strSeq = a.Sequence;
                    if (string.IsNullOrEmpty(strSeq))
                    {
                        strSeq = pwe.GetAutoTypeSequence();
                    }
                    AddSequence(l, strSeq);
                }
            }

            if (Program.Config.Integration.AutoTypeMatchByTitle)
            {
                string strTitle = SprEngine.Compile(pwe.Strings.ReadSafe(
                                                        PwDefs.TitleField).Trim(), sprCtx);
                if ((strTitle.Length > 0) && (strWindow.IndexOf(strTitle,
                                                                StrUtil.CaseIgnoreCmp) >= 0))
                {
                    AddSequence(l, pwe.GetAutoTypeSequence());
                }
            }

            string strCmpUrl = null;             // To cache compiled URL

            if (Program.Config.Integration.AutoTypeMatchByUrlInTitle)
            {
                strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
                                                  PwDefs.UrlField).Trim(), sprCtx);
                if ((strCmpUrl.Length > 0) && (strWindow.IndexOf(strCmpUrl,
                                                                 StrUtil.CaseIgnoreCmp) >= 0))
                {
                    AddSequence(l, pwe.GetAutoTypeSequence());
                }
            }

            if (Program.Config.Integration.AutoTypeMatchByUrlHostInTitle)
            {
                if (strCmpUrl == null)
                {
                    strCmpUrl = SprEngine.Compile(pwe.Strings.ReadSafe(
                                                      PwDefs.UrlField).Trim(), sprCtx);
                }

                string strCleanUrl = StrUtil.RemovePlaceholders(strCmpUrl);
                string strHost     = UrlUtil.GetHost(strCleanUrl);

                if (strHost.StartsWith("www.", StrUtil.CaseIgnoreCmp) &&
                    (strCleanUrl.StartsWith("http:", StrUtil.CaseIgnoreCmp) ||
                     strCleanUrl.StartsWith("https:", StrUtil.CaseIgnoreCmp)))
                {
                    strHost = strHost.Substring(4);
                }

                if ((strHost.Length > 0) && (strWindow.IndexOf(strHost,
                                                               StrUtil.CaseIgnoreCmp) >= 0))
                {
                    AddSequence(l, pwe.GetAutoTypeSequence());
                }
            }

            if (Program.Config.Integration.AutoTypeMatchByTagInTitle)
            {
                foreach (string strTag in pwe.Tags)
                {
                    if (string.IsNullOrEmpty(strTag))
                    {
                        Debug.Assert(false); continue;
                    }

                    if (strWindow.IndexOf(strTag, StrUtil.CaseIgnoreCmp) >= 0)
                    {
                        AddSequence(l, pwe.GetAutoTypeSequence());
                        break;
                    }
                }
            }

            if (AutoType.SequenceQuery != null)
            {
                SequenceQueryEventArgs e = new SequenceQueryEventArgs(iEventID,
                                                                      hWnd, strWindow, pwe, pdContext);
                AutoType.SequenceQuery(null, e);

                foreach (string strSeq in e.Sequences)
                {
                    AddSequence(l, strSeq);
                }
            }

            return(l);
        }