Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
folks
Commits
1ec09812
Commit
1ec09812
authored
Sep 21, 2012
by
Jeremy Whiting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: Add set_persona_stores method to Backend.
eds: Implement set_persona_stores in eds backend.
parent
81a1d481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
9 deletions
+99
-9
backends/eds/eds-backend.vala
backends/eds/eds-backend.vala
+81
-9
folks/backend.vala
folks/backend.vala
+18
-0
No files found.
backends/eds/eds-backend.vala
View file @
1ec09812
...
...
@@ -47,6 +47,7 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
private
HashMap
<
string
,
PersonaStore
>
_persona_stores
;
private
Map
<
string
,
PersonaStore
>
_persona_stores_ro
;
private
E
.
SourceRegistry
_ab_sources
;
private
Set
<
string
>?
_storeids
;
/**
* {@inheritDoc}
...
...
@@ -71,20 +72,81 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
this
.
_remove_address_book
(
store
);
}
}
/**
* {@inheritDoc}
*/
public
override
void
enable_persona_store
(
PersonaStore
store
)
{
if
(!
this
.
_persona_stores
.
has_key
(
store
.
id
))
if
(
this
.
_persona_stores
.
has_key
(
store
.
id
)
==
false
)
{
this
.
_add_persona_store
(
store
);
}
}
private
void
_add_persona_store
(
PersonaStore
store
,
bool
notify
=
true
)
{
store
.
removed
.
connect
(
this
.
_store_removed_cb
);
this
.
_persona_stores
.
set
(
store
.
id
,
store
);
this
.
persona_store_added
(
store
);
if
(
notify
)
{
this
.
notify_property
(
"persona-stores"
);
}
}
/**
* {@inheritDoc}
*/
public
override
void
set_persona_stores
(
Set
<
string
>?
storeids
)
{
this
.
_storeids
=
storeids
;
bool
stores_changed
=
false
;
/* First handle adding any missing persona stores. */
foreach
(
string
id
in
storeids
)
{
if
(
this
.
_persona_stores
.
has_key
(
id
)
==
false
)
{
E
.
Source
?
s
=
this
.
_ab_sources
.
ref_source
(
id
);
if
(
s
==
null
)
{
warning
(
"Unable to reference EDS source with ID %s"
,
id
);
continue
;
}
var
store
=
new
Edsf
.
PersonaStore
.
with_source_registry
(
this
.
_ab_sources
,
s
);
this
.
_add_persona_store
(
store
,
false
);
stores_changed
=
true
;
}
}
/* Keep persona stores to remove in a separate array so we don't
* invalidate the list we are iterating over. */
PersonaStore
[]
stores_to_remove
=
{};
foreach
(
PersonaStore
store
in
this
.
_persona_stores
.
values
)
{
if
(!
storeids
.
contains
(
store
.
id
))
{
stores_to_remove
+=
store
;
stores_changed
=
true
;
}
}
for
(
int
i
=
0
;
i
<
stores_to_remove
.
length
;
++
i
)
{
this
.
_remove_address_book
(
stores_to_remove
[
i
],
false
);
}
/* Finally, if anything changed, emit the persona-stores notification. */
if
(
stores_changed
)
{
store
.
removed
.
connect
(
this
.
_store_removed_cb
);
this
.
_persona_stores
.
set
(
store
.
id
,
store
);
this
.
notify_property
(
"persona-stores"
);
this
.
persona_store_added
(
store
);
}
}
...
...
@@ -100,6 +162,7 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
{
this
.
_persona_stores
=
new
HashMap
<
string
,
PersonaStore
>
();
this
.
_persona_stores_ro
=
this
.
_persona_stores
.
read_only_view
;
this
.
_storeids
=
null
;
}
/**
...
...
@@ -236,6 +299,12 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
{
continue
;
}
if
(
this
.
_storeids
!=
null
&&
!(
uid
in
this
.
_storeids
))
{
continue
;
}
if
(!
this
.
_persona_stores
.
has_key
(
uid
))
{
...
...
@@ -268,14 +337,17 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
this
.
enable_persona_store
(
store
);
}
private
void
_remove_address_book
(
Folks
.
PersonaStore
store
)
private
void
_remove_address_book
(
Folks
.
PersonaStore
store
,
bool
notify
=
true
)
{
debug
(
"Removing address book '%s'."
,
store
.
id
);
this
.
persona_store_removed
(
store
);
this
.
_persona_stores
.
unset
(
store
.
id
);
this
.
notify_property
(
"persona-stores"
);
if
(
notify
)
{
this
.
notify_property
(
"persona-stores"
);
}
store
.
removed
.
disconnect
(
this
.
_store_removed_cb
);
}
...
...
folks/backend.vala
View file @
1ec09812
...
...
@@ -116,6 +116,24 @@ public abstract class Folks.Backend : Object
*/
public
abstract
void
enable_persona_store
(
PersonaStore
store
);
/**
* Set the {@link PersonaStore}s to use in this backend.
*
* This will cause {@link Backend.persona_store_removed} signals to be emitted
* for all removed stores, followed by {@link Backend.persona_store_added}
* signals for all added stores. As these signals are emitted, the sets of
* individuals in any associated {@link IndividualAggregator}s will be
* updated, and {@link IndividualAggregator.individuals_changed} may be
* emitted multiple times as appropriate. A property change notification for
* {@link Backend.persona_stores} will be emitted last.
* Note: pass null storeids to use all available persona stores.
*
* @param storeids a Set of {@link PersonaStore} IDs to use.
*
* @since UNRELEASED
*/
public
abstract
void
set_persona_stores
(
Set
<
string
>?
storeids
);
/**
* Emitted when a {@link PersonaStore} is added to the backend.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment