// HandleFavoritesChanged is called whenever the kbfs favorites change
// for a user (and caches should be invalidated). It will broadcast the
// messages to all curious listeners.
437567
func (n *NotifyRouter) HandleFavoritesChanged(uid keybase1.UID) {
	if n == nil {
		return
	}

	n.G().Log.Debug("+ Sending favorites changed notification")
	// For all connections we currently have open...
	n.cm.ApplyAll(func(id ConnectionID, xp rpc.Transporter) bool {
		// If the connection wants the `Favorites` notification type
		if n.getNotificationChannels(id).Favorites {
			// In the background do...
			go func() {
				// A send of a `FavoritesChanged` RPC with the user's UID
				(keybase1.NotifyFavoritesClient{
					Cli: rpc.NewClient(xp, NewContextifiedErrorUnwrapper(n.G()), nil),
				}).FavoritesChanged(context.Background(), uid)
			}()
		}
		return true
	})

	n.runListeners(func(listener NotifyListener) {
		listener.FavoritesChanged(uid)
	})
	n.G().Log.Debug("- Sent favorites changed notification")
}
1233164
func (fs *KBFSOpsStandard) RegisterForChanges(
	folderBranches []data.FolderBranch, obs Observer) error {
	for _, fb := range folderBranches {
		// TODO: add branch parameter to notifier interface
		ops := fs.getOps(context.Background(), fb, FavoritesOpNoChange)
		return ops.RegisterForChanges(obs)
	}
	return nil
}
1170739
func (s *Settings) SetIfChanged(c context.Context, who, why string) error {
	return settings.SetIfChanged(c, settingsKey, s, who, why)
}
480231
func (s *SimpleFSHandler) SimpleFSListFavorites(ctx context.Context) (
	keybase1.FavoritesResult, error) {
	ctx, cancel := s.wrapContextWithTimeout(ctx)
	defer cancel()
	cli, err := s.client()
	if err != nil {
		return keybase1.FavoritesResult{}, err
	}
	return cli.SimpleFSListFavorites(ctx)
}
413732
func (fl *FolderList) userChanged(ctx context.Context, _, newUser kbname.NormalizedUsername) {
	var fs []*Folder
	func() {
		fl.mu.Lock()
		defer fl.mu.Unlock()
		for _, tlf := range fl.folders {
			if tlf, ok := tlf.(*TLF); ok {
				fs = append(fs, tlf.folder)
			}
		}
	}()
	for _, f := range fs {
		f.TlfHandleChange(ctx, nil)
	}
	if newUser != kbname.NormalizedUsername("") {
		fl.fs.config.KBFSOps().ForceFastForward(ctx)
	}
}
1102513
func (s *Settings) SetIfChanged(c context.Context, key string, value interface{}, who, why string) error {
	// 'value' must be a pointer to a struct. Construct a zero value of this
	// kind of struct.
	typ := reflect.TypeOf(value)
	if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct {
		return ErrBadType
	}
	existing := reflect.New(typ.Elem()).Interface()

	// Fetch existing settings and compare.
	switch err := s.GetUncached(c, key, existing); {
	case err != nil && err != ErrNoSettings:
		return err
	case reflect.DeepEqual(existing, value):
		return nil
	}

	// Log the change. Ignore JSON marshaling errors, they are not essential
	// (and must not happen anyway).
	existingJSON, _ := json.Marshal(existing)
	modifiedJSON, _ := json.Marshal(value)
	logging.Warningf(c, "Settings %q changed from %s to %s by %q", key, existingJSON, modifiedJSON, who)

	return s.Set(c, key, value, who, why)
}
497099
func (h *FavoriteHandler) FavoriteIgnore(ctx context.Context, arg keybase1.FavoriteIgnoreArg) error {
	eng := engine.NewFavoriteIgnore(h.G(), &arg)
	m := libkb.NewMetaContext(ctx, h.G())
	return engine.RunEngine2(m, eng)
}
639657
func (n *NotifyRouter) HandleTrackingChanged(uid keybase1.UID, username NormalizedUsername, isTracking bool) {
	if n == nil {
		return
	}
	arg := keybase1.TrackingChangedArg{
		Uid:        uid,
		Username:   username.String(),
		IsTracking: isTracking,
	}
	// For all connections we currently have open...
	n.cm.ApplyAll(func(id ConnectionID, xp rpc.Transporter) bool {
		// If the connection wants the `Tracking` notification type
		if n.getNotificationChannels(id).Tracking {
			// In the background do...
			go func() {
				// A send of a `TrackingChanged` RPC with the user's UID
				(keybase1.NotifyTrackingClient{
					Cli: rpc.NewClient(xp, NewContextifiedErrorUnwrapper(n.G()), nil),
				}).TrackingChanged(context.Background(), arg)
			}()
		}
		return true
	})
	n.runListeners(func(listener NotifyListener) {
		listener.TrackingChanged(uid, username)
	})
}
469921
func (n *NotifyRouter) HandleFSOnlineStatusChanged(online bool) {
	if n == nil {
		return
	}
	// For all connections we currently have open...
	n.cm.ApplyAll(func(id ConnectionID, xp rpc.Transporter) bool {
		// If the connection wants the `kbfs` notification type
		if n.getNotificationChannels(id).Kbfs {
			// In the background do...
			go func() {
				// A send of a `FSOnlineStatusChanged` RPC with the
				// notification
				(keybase1.NotifyFSClient{
					Cli: rpc.NewClient(xp, NewContextifiedErrorUnwrapper(n.G()), nil),
				}).FSOnlineStatusChanged(context.Background(), online)
			}()
		}
		return true
	})
	n.runListeners(func(listener NotifyListener) {
		listener.FSOnlineStatusChanged(online)
	})
}
746395
func (l Listener) OnUserChange(e *gumble.UserChangeEvent) {
	if l.UserChange != nil {
		l.UserChange(e)
	}
}
814734
func (c *Checkbox) SetChangedFunc(handler func(checked bool)) *Checkbox {
	c.changed = handler
	return c
}
167055
func (i *InputField) SetChangedFunc(handler func(text string)) *InputField {
	i.changed = handler
	return i
}
856143
func GetIfChanged() (*File, error) {
	lastModified.Lock()
	defer lastModified.Unlock()

	resolv, err := ioutil.ReadFile("/etc/resolv.conf")
	if err != nil {
		return nil, err
	}
	newHash, err := ioutils.HashData(bytes.NewReader(resolv))
	if err != nil {
		return nil, err
	}
	if lastModified.sha256 != newHash {
		lastModified.sha256 = newHash
		lastModified.contents = resolv
		return &File{Content: resolv, Hash: newHash}, nil
	}
	// nothing changed, so return no data
	return nil, nil
}
6469
func (k *SimpleFS) SimpleFSListFavorites(ctx context.Context) (
	keybase1.FavoritesResult, error) {
	return k.config.KBFSOps().GetFavoritesAll(ctx)
}
1177226
func (k *KeybaseDaemonLocal) FavoriteDelete(
	ctx context.Context, folder keybase1.Folder) error {
	if err := checkContext(ctx); err != nil {
		return err
	}

	k.lock.Lock()
	defer k.lock.Unlock()
	session, err := k.CurrentSession(ctx, 0)
	if err != nil {
		return err
	}
	return k.favoriteStore.FavoriteDelete(session.UID, folder)
}
558070
func (bucket *kbucket) LastChanged() time.Time {
	bucket.RLock()
	defer bucket.RUnlock()

	return bucket.lastChanged
}
1008604
func (ic *IngressIPController) processChange(change *serviceChange) error {
	service := ic.getCachedService(change.key)

	ic.clearOldAllocation(service, change.oldService)

	if service == nil {
		// Service was deleted - no further processing required
		return nil
	}

	typeLoadBalancer := service.Spec.Type == v1.ServiceTypeLoadBalancer
	hasAllocation := len(service.Status.LoadBalancer.Ingress) > 0
	switch {
	case typeLoadBalancer && hasAllocation:
		return ic.recordAllocation(service, change.key)
	case typeLoadBalancer && !hasAllocation:
		return ic.allocate(service, change.key)
	case !typeLoadBalancer && hasAllocation:
		return ic.deallocate(service, change.key)
	default:
		return nil
	}
}