Esempio n. 1
0
        public PwGroup SearchForHost(Database database, String url, bool allowSubdomains)
        {
            String  host         = ExtractHost(url);
            string  strGroupName = _app.GetResourceString(UiStringKey.search_results) + " (\"" + host + "\")";
            PwGroup pgResults    = new PwGroup(true, true, strGroupName, PwIcon.EMailSearch)
            {
                IsVirtual = true
            };

            if (String.IsNullOrWhiteSpace(host))
            {
                return(pgResults);
            }
            foreach (PwEntry entry in database.EntriesById.Values)
            {
                if (!entry.GetSearchingEnabled())
                {
                    continue;
                }
                string otherUrl = entry.Strings.ReadSafe(PwDefs.UrlField);
                otherUrl = SprEngine.Compile(otherUrl, new SprContext(entry, database.KpDatabase, SprCompileFlags.References));
                String otherHost = ExtractHost(otherUrl);
                if ((allowSubdomains) && (otherHost.StartsWith("www.")))
                {
                    otherHost = otherHost.Substring(4);                     //remove "www."
                }
                if (String.IsNullOrWhiteSpace(otherHost))
                {
                    continue;
                }
                if (host.IndexOf(otherHost, StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    pgResults.AddEntry(entry, false);
                }
            }
            return(pgResults);
        }
Esempio n. 2
0
        private static bool GetString(PwEntry pe, string strName, SprContext ctx,
                                      bool bTrim, out string strValue)
        {
            if ((pe == null) || (strName == null))
            {
                Debug.Assert(false);
                strValue = string.Empty;
                return(false);
            }

            string str = pe.Strings.ReadSafe(strName);

            if (ctx != null)
            {
                str = SprEngine.Compile(str, ctx);
            }
            if (bTrim)
            {
                str = str.Trim();
            }

            strValue = str;
            return(str.Length != 0);
        }
Esempio n. 3
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                if (cursorInflater == null)
                {
                    cursorInflater = (LayoutInflater)_context.GetSystemService(Context.LayoutInflaterService);
                }

                View view;

                if (convertView == null)
                {
                    // if it's not recycled, initialize some attributes

                    view = cursorInflater.Inflate(Resource.Layout.child_db_config_row, parent, false);


                    view.FindViewById <Button>(Resource.Id.child_db_enable_on_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEnable(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };

                    view.FindViewById <Button>(Resource.Id.child_db_disable_on_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnDisable(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_edit).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEdit(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_open).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnOpen(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };


                    view.FindViewById <Button>(Resource.Id.child_db_enable_a_copy_for_this_device).Click += (sender, args) =>
                    {
                        View sending_view = (View)sender;
                        _context.OnEnableCopy(_displayedChildDatabases[GetClickedPos(sending_view)]);
                    };
                }
                else
                {
                    view = convertView;
                }


                var iv           = view.FindViewById <ImageView>(Resource.Id.child_db_icon);
                var autoExecItem = _displayedChildDatabases[position];
                var pw           = autoExecItem.Entry;

                SprContext ctx = new SprContext(pw, App.Kp2a.FindDatabaseForElement(pw).KpDatabase, SprCompileFlags.All);

                string deviceId = KeeAutoExecExt.ThisDeviceId;

                view.FindViewById <TextView>(Resource.Id.child_db_title).Text =
                    SprEngine.Compile(pw.Strings.GetSafe(PwDefs.TitleField).ReadString(), ctx);

                view.FindViewById <TextView>(Resource.Id.child_db_url).Text =
                    _context.GetString(Resource.String.entry_url) + ": " + SprEngine.Compile(pw.Strings.GetSafe(PwDefs.UrlField).ReadString(), ctx);

                bool deviceEnabledExplict;
                bool deviceEnabled = KeeAutoExecExt.IsDeviceEnabled(autoExecItem, deviceId, out deviceEnabledExplict);

                deviceEnabled &= deviceEnabledExplict;


                if (!autoExecItem.Enabled)
                {
                    view.FindViewById <TextView>(Resource.Id.child_db_enabled_here).Text =
                        _context.GetString(Resource.String.plugin_disabled);
                }
                else
                {
                    view.FindViewById <TextView>(Resource.Id.child_db_enabled_here).Text =
                        _context.GetString(Resource.String.child_db_enabled_on_this_device) + ": " +
                        (!deviceEnabledExplict ?
                         _context.GetString(Resource.String.unspecified)
                            :
                         ((autoExecItem.Enabled && deviceEnabled)
                                ? _context.GetString(Resource.String.yes)
                                : _context.GetString(Resource.String.no)));
                }

                view.FindViewById(Resource.Id.child_db_enable_on_this_device).Visibility  = !deviceEnabled && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_disable_on_this_device).Visibility = (deviceEnabled || !deviceEnabledExplict) && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_enable_a_copy_for_this_device_container).Visibility = !deviceEnabled && autoExecItem.Enabled ? ViewStates.Visible : ViewStates.Gone;
                view.FindViewById(Resource.Id.child_db_edit).Visibility = deviceEnabledExplict || !autoExecItem.Enabled  ? ViewStates.Visible : ViewStates.Gone;
                IOConnectionInfo ioc;

                if ((KeeAutoExecExt.TryGetDatabaseIoc(autoExecItem, out ioc)) && App.Kp2a.TryGetDatabase(ioc) == null)
                {
                    view.FindViewById(Resource.Id.child_db_open).Visibility = ViewStates.Visible;
                }
                else
                {
                    view.FindViewById(Resource.Id.child_db_open).Visibility = ViewStates.Gone;
                }


                Database db = App.Kp2a.FindDatabaseForElement(pw);

                bool isExpired = pw.Expires && pw.ExpiryTime < DateTime.Now;

                if (isExpired)
                {
                    db.DrawableFactory.AssignDrawableTo(iv, _context, db.KpDatabase, PwIcon.Expired, PwUuid.Zero, false);
                }
                else
                {
                    db.DrawableFactory.AssignDrawableTo(iv, _context, db.KpDatabase, pw.IconId, pw.CustomIconUuid, false);
                }



                view.Tag = position.ToString();

                return(view);
            }