File libcloudproviders-0.3.6.obscpio of Package libcloudproviders

07070100000000000081A400000000000000000000000165FAB1390000015F000000000000000000000000000000000000002600000000libcloudproviders-0.3.6/.editorconfig# SPDX-FileCopyrightText: 2023 The libcloudproviders authors
# SPDX-License-Identifier: CC0-1.0

root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true

[*.[ch]]
indent_size = 4
indent_style = space
insert_final_newline = true

[*.xml]
indent_size = 2
indent_style = space

[meson.build]
indent_size = 2
indent_style = space07070100000001000081A400000000000000000000000165FAB1390000001A000000000000000000000000000000000000002300000000libcloudproviders-0.3.6/.gitignore/build
/src/*-generated.*
07070100000002000081A400000000000000000000000165FAB1390000022B000000000000000000000000000000000000002700000000libcloudproviders-0.3.6/.gitlab-ci.ymlimage: fedora:37
stages:
  - build
  - deploy
before_script:
  - dnf install -y gcc meson ninja-build gettext gtk-doc glib2-devel gobject-introspection-devel vala redhat-rpm-config

build-libcloudproviders:
  stage: build
  script:
  - meson _build .
  - ninja -C _build
  - ninja -C _build install

pages:
  stage: deploy
  script:
  - meson _build . -Denable-gtk-doc=true
  - ninja libcloudproviders-doc -C _build
  - mv _build/docs/reference/html public
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
07070100000003000081A400000000000000000000000165FAB1390000036D000000000000000000000000000000000000002200000000libcloudproviders-0.3.6/CHANGELOG0.3.6
-----
* Plug several memory leaks
* Avoid use-after-free within the Proxy
* Renamespace CloudProvidersProvider
* Reduce a bit the CloudProvidersAccount memory footprint

0.3.5
-----
* Avoid use after free with g_bus_get

0.3.4
-----
* Re-release du to release tarball issue

0.3.3
-----
* Use a new way to register providers using .desktop files

0.3.0
-----
* Provide Vala bindings (Fernando da Silva)
* Fix dbus server path (Fernando da Silva)
* Use option for includedir (Jan Tojnar)
* Fix crash when using more than one file chooser (Jan Alexander)

0.2.5
-----
* Drop the daemon and do the cloud providers query client side.
* Update the API with proper prefixes as recommended for GObject libraries.
* Convert DBUS functions to properties, to allow notify:: signals.
* Add a flag for conditional install the tests.

0.1.0
-----
* First release of libcloudproviders
07070100000004000081A400000000000000000000000165FAB13900001DE3000000000000000000000000000000000000002000000000libcloudproviders-0.3.6/LICENSE                   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.


  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

  0. Additional Definitions.

  As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

  "The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

  An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

  A "Combined Work" is a work produced by combining or linking an
Application with the Library.  The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

  The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

  The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

  1. Exception to Section 3 of the GNU GPL.

  You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

  2. Conveying Modified Versions.

  If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

   a) under this License, provided that you make a good faith effort to
   ensure that, in the event an Application does not supply the
   function or data, the facility still operates, and performs
   whatever part of its purpose remains meaningful, or

   b) under the GNU GPL, with none of the additional permissions of
   this License applicable to that copy.

  3. Object Code Incorporating Material from Library Header Files.

  The object code form of an Application may incorporate material from
a header file that is part of the Library.  You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

   a) Give prominent notice with each copy of the object code that the
   Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the object code with a copy of the GNU GPL and this license
   document.

  4. Combined Works.

  You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

   a) Give prominent notice with each copy of the Combined Work that
   the Library is used in it and that the Library and its use are
   covered by this License.

   b) Accompany the Combined Work with a copy of the GNU GPL and this license
   document.

   c) For a Combined Work that displays copyright notices during
   execution, include the copyright notice for the Library among
   these notices, as well as a reference directing the user to the
   copies of the GNU GPL and this license document.

   d) Do one of the following:

       0) Convey the Minimal Corresponding Source under the terms of this
       License, and the Corresponding Application Code in a form
       suitable for, and under terms that permit, the user to
       recombine or relink the Application with a modified version of
       the Linked Version to produce a modified Combined Work, in the
       manner specified by section 6 of the GNU GPL for conveying
       Corresponding Source.

       1) Use a suitable shared library mechanism for linking with the
       Library.  A suitable mechanism is one that (a) uses at run time
       a copy of the Library already present on the user's computer
       system, and (b) will operate properly with a modified version
       of the Library that is interface-compatible with the Linked
       Version.

   e) Provide Installation Information, but only if you would otherwise
   be required to provide such information under section 6 of the
   GNU GPL, and only to the extent that such information is
   necessary to install and execute a modified version of the
   Combined Work produced by recombining or relinking the
   Application with a modified version of the Linked Version. (If
   you use option 4d0, the Installation Information must accompany
   the Minimal Corresponding Source and Corresponding Application
   Code. If you use option 4d1, you must provide the Installation
   Information in the manner specified by section 6 of the GNU GPL
   for conveying Corresponding Source.)

  5. Combined Libraries.

  You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

   a) Accompany the combined library with a copy of the same work based
   on the Library, uncombined with any other library facilities,
   conveyed under the terms of this License.

   b) Give prominent notice with the combined library that part of it
   is a work based on the Library, and explaining where to find the
   accompanying uncombined form of the same work.

  6. Revised Versions of the GNU Lesser General Public License.

  The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

  Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

  If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
07070100000005000081A400000000000000000000000165FAB139000002A3000000000000000000000000000000000000002200000000libcloudproviders-0.3.6/README.md# cloudproviders integration API

libcloudproviders is a DBus API that allows cloud storage sync clients to expose
their services. Clients such as file managers and desktop environments can then
provide integrated access to the cloud providers services.

More information on its uses in [this blog post](https://csorianognome.wordpress.com/2015/07/07/cloud-providers/).

## API Documentation

See the [API documentation](https://world.pages.gitlab.gnome.org/libcloudproviders/) for
further details.

# Integrated by
### Server
- Nextcloud client 2.5
### Client
- GNOME Nautilus (file manager used by default in Fedora, Ubuntu, OpenSuse, Debian, RHEL, Suse..)
- elementary OS
07070100000006000041ED00000000000000000000000265FAB13900000000000000000000000000000000000000000000001D00000000libcloudproviders-0.3.6/data07070100000007000081A400000000000000000000000165FAB13900000568000000000000000000000000000000000000003600000000libcloudproviders-0.3.6/data/cloud-providers-dbus.xml<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

<!--
 This file is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as
 published by the Free Software Foundation; either version 3 of the
 License, or (at your option) any later version.

 This file is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this program.  If not, see <http://www.gnu.org/licenses/>.

 SPDX-License-Identifier: LGPL-3.0-or-later
-->
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
  <interface name='org.freedesktop.CloudProviders.Provider'>
    <property name="Name" type="s" access="read"/>
  </interface>

  <interface name='org.freedesktop.CloudProviders.Account'>
    <property name="Name" type="s" access="read"/>
    <property name="Path" type="s" access="read"/>
    <property name="Icon" type="s" access="read"/>
    <property name="Status" type="i" access="read"/>
    <property name="StatusDetails" type="s" access="read"/>
  </interface>
</node>
07070100000008000041ED00000000000000000000000265FAB13900000000000000000000000000000000000000000000001D00000000libcloudproviders-0.3.6/docs07070100000009000041ED00000000000000000000000265FAB13900000000000000000000000000000000000000000000002700000000libcloudproviders-0.3.6/docs/reference0707010000000A000081A400000000000000000000000165FAB13900000011000000000000000000000000000000000000003200000000libcloudproviders-0.3.6/docs/reference/.gitignore*generated-docs*
0707010000000B000081A400000000000000000000000165FAB13900000577000000000000000000000000000000000000003E00000000libcloudproviders-0.3.6/docs/reference/integration-client.xml<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<chapter id="implementing-cps">
  <title>Integrating with cloud providers</title>
  <para>
    Integration with cloud providers can be achieved by fetching a list of exported
    cloud provider accounts using <link linkend="cloud_providers_collector_get_providers()">cloud_providers_collector_get_providers()</link>. This function returns
    a list of #CloudProvidersProvider objects that can then be used to obtain details about
    the providers. Each #CloudProvidersProvider holds a list of #CloudProvidersAccount
    that can be query using cloud_providers_provider_get_accounts().
  </para>
  <para>
    To get notified about changes in either the #CloudProvidersProvider or each of
      their #CloudProvidersAccount you can connect to the "notify::" signal of
      each of their properties. Any UI elements should be updated after receiving
      this signal.
  </para>
  <para>
    Besides the account details, #CloudProvidersAccount may also export a #GMenuModel and a #GActionGroup
    to provide actions that are related with the account. Those can be obtained by calling
    cloud_providers_account_get_menu_model() and cloud_providers_account_get_action_group().
  </para>
</chapter>
0707010000000C000081A400000000000000000000000165FAB1390000087F000000000000000000000000000000000000003E00000000libcloudproviders-0.3.6/docs/reference/integration-server.xml<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
    <chapter id="implementing-cp">
      <title>Implementing support as a cloud provider</title>
      <para>
        Cloud providers need to create #CloudProvidersAccountExporter objects for
        every account they like to expose to the API and use the #CloudProvidersAccountExporter
        API to set the properties of the accounts. Also a #CloudProvidersProviderExporter
        needs to be created in order to hold all the #CloudProvidersAccountExporter objects
        that will be added to the provider when created.
        #CloudProvidersProviderExporter also export properties that define the provider
        that can be set using the #CloudProvidersProviderExporter API.
      </para>
      <para>
        To register your cloud provider, you need to expose the interface it is implementing in its desktop file
      </para>
      <example>
        <title>Example desktop file to register a cloud provider</title>
        <programlisting>
          [Desktop Entry]
          Type=Application
          Name=mycloudprovider example server
          NoDisplay=true
          Implements=org.freedesktop.CloudProviders

          [org.freedesktop.CloudProviders]
          BusName=org.mycloudprovider.CloudProviders.ServerExample
          ObjectPath=/org/mycloudprovider/CloudProviders/ServerExample
        </programlisting>
      </example>
      <para>
        In previous versions, to register your cloud provider you needed to provide a file in DATADIR/cloud-providers.
        This way of registering providers is still working but is not compatible with containerization.
      </para>
      <example>
        <title>Example file to register a cloud provider in previous versions</title>
        <programlisting>
          [Cloud Provider]
          BusName=org.mycloudprovider.CloudProviders.ServerExample
          ObjectPath=/org/mycloudprovider/CloudProviders/ServerExample
          Version=1
        </programlisting>
      </example>
    </chapter>
0707010000000D000081A400000000000000000000000165FAB13900000DE1000000000000000000000000000000000000004200000000libcloudproviders-0.3.6/docs/reference/libcloudproviders-docs.xml<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
  <bookinfo>
    <title>CloudProviders Reference Manual</title>
    <releaseinfo>Cloudproviders &version;</releaseinfo>
    <authorgroup>
      <author>
        <firstname>Julius</firstname>
        <surname>Härtl</surname>
        <affiliation>
          <address>
            <email>jus@bitgrid.net</email>
          </address>
        </affiliation>
      </author>
      <author>
        <firstname>Carlos</firstname>
        <surname>Soriano</surname>
        <affiliation>
          <address>
            <email>csoriano@gnome.org</email>
          </address>
        </affiliation>
      </author>
    </authorgroup>
    <copyright>
      <year>2017</year>
      <holder>Julius Härtl</holder>
      <year>2017</year>
      <holder>Carlos Soriano</holder>
    </copyright>
  </bookinfo>

  <part id="libcloudproviders">
    <title>libcloudproviders library</title>
    <partintro>
      <para>
          This part documents libcloudproviders library. The library is meant to be used
          as a C interface with their respective language bindings through introspection.
          However, it can also be used with raw DBus management. If that's the
          case, make sure it implements the DBus interfaces explained at
          <link linkend="cloudproviders-dbus">cloudproviders-dbus</link>.
      </para>
    </partintro>
    <xi:include href="xml/cloudproviderscollector.xml"/>
    <xi:include href="xml/cloudprovidersproviderexporter.xml"/>
    <xi:include href="xml/cloudprovidersaccountexporter.xml"/>
    <xi:include href="xml/cloudprovidersaccount.xml"/>
    <xi:include href="xml/cloudprovidersprovider.xml"/>
  </part>

  <part id="libcloudproviders-integration">
    <title>Integrating libcloudproviders</title>
    <xi:include href="integration-server.xml" />
    <xi:include href="integration-client.xml" />
  </part>

  <part id="cloudproviders-dbus">
    <title>DBus Interfaces</title>
    <partintro>
      <para>
    cloud provider accounts using <link linkend="cloud_providers_collector_get_providers()">cloud_providers_collector_get_providers()</link>. This function returns
          cloud-providers-collector-get-providers()
         #CloudProvidersCollector.signals
          cloudprovidersprovider
         <link href="glib-Hash-Tables">Hash Tables</link>
         <link href="#CloudProvidersProvider.signals">Hash Tables</link>
         <link href="CloudProvidersCollector.html#cloud-providers-collector-get-providers">Hash Tables</link>
          The DBus object that is passed to cloud_providers_provider_exporter_new() will implement the <ulink
          url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager">org.freedesktop.DBus.ObjectManager</ulink>
          interface, and that can be used by clients to discover and query
          objects like the provider properties itself or the accounts associated
          with your provider.
      </para>
    </partintro>
    <xi:include href="generated-docs-org.freedesktop.CloudProviders.Account.xml"/>
    <xi:include href="generated-docs-org.freedesktop.CloudProviders.Provider.xml"/>
  </part>
  <index id="index-all">
    <title>Index of all symbols</title>
  </index>
  <xi:include href="xml/annotation-glossary.xml"><xi:fallback/></xi:include>

</book>
0707010000000E000081A400000000000000000000000165FAB1390000080D000000000000000000000000000000000000004600000000libcloudproviders-0.3.6/docs/reference/libcloudproviders-sections.txt<SECTION>
<FILE>cloudprovidersaccount</FILE>
<TITLE>CloudProvidersAccount</TITLE>
CloudProvidersAccountStatus
CLOUD_PROVIDERS_ACCOUNT_DBUS_IFACE
CLOUD_PROVIDERS_TYPE_ACCOUNT
CloudProvidersAccountClass
cloud_providers_account_new
cloud_providers_account_get_name
cloud_providers_account_get_status
cloud_providers_account_get_status_details
cloud_providers_account_get_icon
cloud_providers_account_get_menu_model
cloud_providers_account_get_action_group
cloud_providers_account_get_path
CloudProvidersAccount
</SECTION>

<SECTION>
<FILE>cloudprovidersaccountexporter</FILE>
<TITLE>CloudProvidersAccountExporter</TITLE>
CLOUD_PROVIDERS_TYPE_ACCOUNT_EXPORTER
CloudProvidersAccountExporterClass
cloud_providers_account_exporter_new
cloud_providers_account_exporter_set_name
cloud_providers_account_exporter_set_status
cloud_providers_account_exporter_set_status_details
cloud_providers_account_exporter_set_icon
cloud_providers_account_exporter_set_menu_model
cloud_providers_account_exporter_set_action_group
cloud_providers_account_exporter_set_path
CloudProvidersAccountExporter
</SECTION>

<SECTION>
<FILE>cloudproviderscollector</FILE>
<TITLE>CloudProvidersCollector</TITLE>
CLOUD_PROVIDERS_TYPE_COLLECTOR
CloudProvidersCollectorClass
cloud_providers_collector_dup_singleton
cloud_providers_collector_get_providers
cloud_providers_collector_update
CloudProvidersCollector
</SECTION>

<SECTION>
<FILE>cloudprovidersprovider</FILE>
<TITLE>CloudProvidersProvider</TITLE>
CLOUD_PROVIDERS_PROVIDER_DBUS_IFACE
CLOUD_PROVIDERS_TYPE_PROVIDER
cloud_providers_provider_new
cloud_providers_provider_get_name
cloud_providers_provider_get_accounts
CloudProvidersProvider
</SECTION>

<SECTION>
<FILE>cloudprovidersproviderexporter</FILE>
<TITLE>CloudProvidersProviderExporter</TITLE>
CLOUD_PROVIDERS_TYPE_PROVIDER_EXPORTER
CloudProvidersProviderExporterClass
cloud_providers_provider_exporter_new
cloud_providers_provider_exporter_remove_account
cloud_providers_provider_exporter_set_name
cloud_providers_provider_exporter_get_name
CloudProvidersProviderExporter
</SECTION>
0707010000000F000081A400000000000000000000000165FAB1390000044B000000000000000000000000000000000000003300000000libcloudproviders-0.3.6/docs/reference/meson.buildcdata = configuration_data()
cdata.set('VERSION', meson.project_version())
configure_file(input: 'version.xml.in',
               output: 'version.xml',
               configuration: cdata)

codegen = find_program('gdbus-codegen')
message ('----------------------------')
message('Generating DBUS docs…')
run_command('gdbus-codegen', '--generate-docbook', 'generated-docs',
            join_paths(meson.source_root(), 'data/cloud-providers-dbus.xml'),
            '--output-directory', join_paths(meson.source_root(), 'docs/reference'))

gnome.gtkdoc('libcloudproviders',
             src_dir: join_paths (meson.source_root(), 'src'),
             dependencies: [libcloudproviders_dep],
             gobject_typesfile: 'libcloudproviders.types',
             main_xml: 'libcloudproviders-docs.xml',
             content_files: ['generated-docs-org.freedesktop.CloudProviders.Account.xml',
                             'generated-docs-org.freedesktop.CloudProviders.Provider.xml'],
             install : true,
             scan_args: ['--rebuild-types'])

message ('----------------------------')
07070100000010000081A400000000000000000000000165FAB1390000000A000000000000000000000000000000000000003600000000libcloudproviders-0.3.6/docs/reference/version.xml.in@VERSION@
07070100000011000081A400000000000000000000000165FAB13900000620000000000000000000000000000000000000002F00000000libcloudproviders-0.3.6/libcloudproviders.doap<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:gnome="http://api.gnome.org/doap-extensions#"
         xmlns="http://usefulinc.com/ns/doap#">

  <name xml:lang="en">libcloudproviders</name>
  <shortdesc xml:lang="en">Cross desktop library for cloud providers</shortdesc>
  <description xml:lang="en">
    A cross desktop library for integration with file managers and other tools for cloud providers and sync tools.
  </description>
  <programming-language>C</programming-language>

  <category rdf:resource="http://api.gnome.org/doap-extensions#apps" />
  <homepage rdf:resource="https://gitlab.gnome.org/GNOME/libcloudproviders" />
  <bug-database rdf:resource="https://gitlab.gnome.org/GNOME/libcloudproviders/issues" />

  <maintainer>
    <foaf:Person>
      <foaf:name>Julius Haertl</foaf:name>
      <foaf:mbox rdf:resource="mailto:jus@bitgrid.net" />
    </foaf:Person>
  </maintainer>

  <maintainer>
    <foaf:Person>
      <foaf:name>Carlos Soriano</foaf:name>
      <foaf:mbox rdf:resource="mailto:csoriano@gnome.org" />
      <gnome:userid>csoriano</gnome:userid>
    </foaf:Person>
  </maintainer>

  <maintainer>
    <foaf:Person>
      <foaf:name>Corentin Noël</foaf:name>
      <foaf:mbox rdf:resource="mailto:corentin.noel@collabora.com" />
      <gnome:userid>corentinnoel</gnome:userid>
    </foaf:Person>
  </maintainer>

  <license rdf:resource="https://www.gnu.org/licenses/lgpl-3.0.txt" />

</Project>
07070100000012000081A400000000000000000000000165FAB13900000915000000000000000000000000000000000000002400000000libcloudproviders-0.3.6/meson.buildproject ('libcloudproviders', 'c',
  version: '0.3.6',
  meson_version: '>=0.54.0',
  license: 'LGPL3+',
  default_options: [
    'c_std=gnu99',
    'warning_level=2',
  ]
)

libcloudproviders_minor_version = meson.project_version().split('.')[1].to_int()
libcloudproviders_micro_version = meson.project_version().split('.')[2].to_int()

libcloudproviders_api_version = '0.3'
libcloudproviders_soversion = '0'
libcloudproviders_library_version = '@0@.@1@.@2@'.format(libcloudproviders_soversion, libcloudproviders_minor_version, libcloudproviders_micro_version)

cc = meson.get_compiler('c')

test_cflags = [
  '-Wno-unused-parameter',
  '-Wno-missing-field-initializers',
  '-Wstrict-prototypes',
  '-Wmissing-prototypes',
  '-Werror=implicit-function-declaration',
  '-Werror=pointer-arith',
  '-Werror=init-self',
  ['-Werror=format-security','-Werror=format=1'],
  '-Werror=date-time',
]
global_cflags = []
foreach cflag : test_cflags
  if cc.has_multi_arguments(cflag)
    global_cflags += cflag
  endif
endforeach
add_project_arguments(global_cflags, language: 'c')

glib_req_version = '2.56'
glib_ver = '>= @0@'.format(glib_req_version)
glib = dependency ('glib-2.0', version: glib_ver)
gio = dependency ('gio-2.0', version: glib_ver)

host_os = host_machine.system().to_lower()
if host_os.contains('mingw') or host_os.contains('cygwin') or host_os.contains('windows')
    gio_platform = dependency ('gio-windows-2.0', version: glib_ver)
else
    gio_platform = dependency ('gio-unix-2.0', version: glib_ver)
endif

add_project_arguments(
  '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_@0@_@1@'.format(glib_req_version.split('.')[0], glib_req_version.split('.')[1]),
  '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_@0@_@1@'.format(glib_req_version.split('.')[0], glib_req_version.split('.')[1]),
  language: 'c'
)

prefix = get_option ('prefix')
libdir = get_option ('libdir')
libexecdir = get_option ('libexecdir')
bindir = get_option ('bindir')
datadir = get_option ('datadir')
servicedir = join_paths (datadir, 'dbus-1', 'services')
incdir = join_paths (prefix, get_option('includedir'), 'cloudproviders')
girdir= join_paths(datadir, 'gir-1.0')
typelibdir = join_paths(libdir, 'girepository-1.0')

gnome = import('gnome')

subdir ('src')
subdir ('test')
if get_option ('enable-gtk-doc')
    subdir ('docs/reference')
endif
07070100000013000081A400000000000000000000000165FAB13900000157000000000000000000000000000000000000002A00000000libcloudproviders-0.3.6/meson_options.txtoption('enable-gtk-doc', type: 'boolean', value: false)
option('installed-tests', type: 'boolean', value: false)
option(
  'introspection',
  type: 'boolean',
  value: true,
  description: 'Build GObject introspection data for extension library',
)
option(
  'vapigen',
  type: 'boolean',
  value: true,
  description: 'Build Vala bindings',
)07070100000014000041ED00000000000000000000000265FAB13900000000000000000000000000000000000000000000001C00000000libcloudproviders-0.3.6/src07070100000015000081A400000000000000000000000165FAB13900000160000000000000000000000000000000000000002D00000000libcloudproviders-0.3.6/src/cloudproviders.h#ifndef CLOUDPROVIDERS_H
#define CLOUDPROVIDERS_H

#define CLOUDPROVIDERS_INSIDE
#include "enums.h"
#include "cloudprovidersaccount.h"
#include "cloudprovidersaccountexporter.h"
#include "cloudproviderscollector.h"
#include "cloudprovidersprovider.h"
#include "cloudprovidersproviderexporter.h"
#undef CLOUDPROVIDERS_INSIDE

#endif // CLOUDPROVIDERS_H
07070100000016000081A400000000000000000000000165FAB13900003B28000000000000000000000000000000000000003400000000libcloudproviders-0.3.6/src/cloudprovidersaccount.c/* cloudprovidersaccount.c
 *
 * Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "cloudprovidersaccount.h"
#include "cloudprovidersprovider.h"
#include "cloudproviders-generated.h"
#include "enums.h"

struct _CloudProvidersAccount
{
  GObject parent;

  gchar *name;
  gchar *path;
  CloudProvidersAccountStatus status;
  gchar *status_details;
  GIcon *icon;
  GMenuModel *menu_model;
  GActionGroup *action_group;

  GDBusConnection *bus;
  CloudProvidersDbusAccount *proxy; // Owned by bus
};

G_DEFINE_TYPE (CloudProvidersAccount, cloud_providers_account, G_TYPE_OBJECT)

/**
 * SECTION:cloudprovidersaccount
 * @title: CloudProvidersAccount
 * @short_description: Base object for representing a single account for clients.
 * @include: src/cloudprovideraccount.h
 *
 * #CloudProvidersAccount is the basic object used to construct the integrator UI
 * and actions that a provider will present to the user, from the client side.
 * Integrators of the cloud providers can use this object to poll the
 * #CloudProvidersProvider menus, status and actions.
 */

enum
{
    PROP_0,
    PROP_NAME,
    PROP_ICON,
    PROP_STATUS,
    PROP_STATUS_DETAILS,
    PROP_MENU_MODEL,
    PROP_ACTION_GROUP,
    PROP_PATH,
    N_PROPS
};

static GParamSpec *properties [N_PROPS];

static void
on_name_changed (GObject               *object,
                 GParamSpec            *pspec,
                 CloudProvidersAccount *self)
{
    g_free (self->name);
    self->name = cloud_providers_dbus_account_dup_name (self->proxy);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_NAME]);
}

static void
on_status_changed (GObject               *object,
                   GParamSpec            *pspec,
                   CloudProvidersAccount *self)
{
    self->status = cloud_providers_dbus_account_get_status (self->proxy);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATUS]);
}

static void
on_status_details_changed (GObject               *object,
                           GParamSpec            *pspec,
                           CloudProvidersAccount *self)
{
    g_free (self->status_details);
    self->status_details = cloud_providers_dbus_account_dup_status_details (self->proxy);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATUS_DETAILS]);
}

static void
on_icon_changed (GObject               *object,
                 GParamSpec            *pspec,
                 CloudProvidersAccount *self)
{
    GError *error = NULL;

    self->icon = g_icon_new_for_string (cloud_providers_dbus_account_get_icon (self->proxy), &error);
    if (error != NULL)
    {
        g_printerr ("Error getting the icon in the client %s", error->message);
    }
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
}

static void
on_path_changed (GObject               *object,
                 GParamSpec            *pspec,
                 CloudProvidersAccount *self)
{
    g_free (self->path);
    self->path = cloud_providers_dbus_account_dup_path (self->proxy);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PATH]);
}

static void
setup_proxy (CloudProvidersAccount *self)
{
    GMenuModel *menu_model;
    GActionGroup *action_group;
    GIcon *icon = NULL;
    GError *error = NULL;
    g_autofree gchar *bus_name = NULL;
    const gchar *object_path;

    g_signal_connect (self->proxy, "notify::name", G_CALLBACK (on_name_changed), self);
    g_signal_connect (self->proxy, "notify::status", G_CALLBACK (on_status_changed), self);
    g_signal_connect (self->proxy, "notify::status-details", G_CALLBACK (on_status_details_changed), self);
    g_signal_connect (self->proxy, "notify::icon", G_CALLBACK (on_icon_changed), self);
    g_signal_connect (self->proxy, "notify::path", G_CALLBACK (on_path_changed), self);

    icon = g_icon_new_for_string (cloud_providers_dbus_account_get_icon (self->proxy), &error);
    if (error != NULL)
    {
        g_printerr ("Error getting the icon in the client %s", error->message);
    }

    bus_name = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (self->proxy));
    object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (self->proxy));
    menu_model = (GMenuModel*) g_dbus_menu_model_get (self->bus,
                                                      bus_name,
                                                      object_path);
    action_group = (GActionGroup*) g_dbus_action_group_get (self->bus,
                                                            bus_name,
                                                            object_path);
    self->name = cloud_providers_dbus_account_dup_name (self->proxy);
    self->status = cloud_providers_dbus_account_get_status (self->proxy);
    self->status_details = cloud_providers_dbus_account_dup_status_details (self->proxy);
    self->icon = icon;
    self->path = cloud_providers_dbus_account_dup_path (self->proxy);
    self->menu_model = menu_model;
    self->action_group = action_group;

    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_NAME]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATUS]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATUS_DETAILS]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PATH]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTION_GROUP]);
    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MENU_MODEL]);
}

static void
cloud_providers_account_get_property (GObject    *object,
                                      guint       prop_id,
                                      GValue     *value,
                                      GParamSpec *pspec)
{
    CloudProvidersAccount *self = CLOUD_PROVIDERS_ACCOUNT (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_value_set_string (value, self->name);
        }
        break;

        case PROP_STATUS:
        {
            g_value_set_enum (value, self->status);
        }
        break;

        case PROP_STATUS_DETAILS:
        {
            g_value_set_string (value, self->status_details);
        }
        break;

        case PROP_ICON:
        {
            g_value_set_object (value, self->icon);
        }
        break;

        case PROP_PATH:
        {
            g_value_set_string (value, self->path);
        }
        break;

        case PROP_ACTION_GROUP:
        {
            g_value_set_object (value, self->action_group);
        }
        break;

        case PROP_MENU_MODEL:
        {
            g_value_set_object (value, self->menu_model);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }
    }
}

static void
cloud_providers_account_set_property (GObject      *object,
                                      guint         prop_id,
                                      const GValue *value,
                                      GParamSpec   *pspec)
{
    switch (prop_id)
    {
        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }

    }
}

/**
 * cloud_providers_account_new
 * @proxy: DBus proxy
 *
 * A #CloudProvidersAccount object are used to fetch details about cloud providers from DBus.
 * Object are usually fetched from cloud_providers_provider_get_accounts() as a list.
 */
CloudProvidersAccount*
cloud_providers_account_new (GDBusProxy *proxy)
{
  CloudProvidersAccount *self;

  g_return_val_if_fail (CLOUD_PROVIDERS_DBUS_IS_ACCOUNT (proxy), NULL);

  self = g_object_new (CLOUD_PROVIDERS_TYPE_ACCOUNT, NULL);

  self->proxy = CLOUD_PROVIDERS_DBUS_ACCOUNT (g_object_ref (proxy));
  self->bus = g_dbus_proxy_get_connection (G_DBUS_PROXY (self->proxy));

  setup_proxy (self);

  return self;
}

static void
cloud_providers_account_dispose (GObject *object)
{
    CloudProvidersAccount *self = (CloudProvidersAccount *)object;

    g_clear_object (&self->icon);
    g_clear_object (&self->action_group);
    g_clear_object (&self->menu_model);
    if (self->proxy)
        g_signal_handlers_disconnect_by_data (self->proxy, self);
    g_clear_object (&self->proxy);

    G_OBJECT_CLASS (cloud_providers_account_parent_class)->dispose (object);
}

static void
cloud_providers_account_finalize (GObject *object)
{
    CloudProvidersAccount *self = (CloudProvidersAccount *)object;

    g_clear_pointer (&self->name, g_free);
    g_clear_pointer (&self->path, g_free);
    g_clear_pointer (&self->status_details, g_free);

    G_OBJECT_CLASS (cloud_providers_account_parent_class)->finalize (object);
}

static void
cloud_providers_account_class_init (CloudProvidersAccountClass *klass)
{
    GObjectClass *object_class = G_OBJECT_CLASS (klass);

    object_class->dispose = cloud_providers_account_dispose;
    object_class->finalize = cloud_providers_account_finalize;
    object_class->set_property = cloud_providers_account_set_property;
    object_class->get_property = cloud_providers_account_get_property;

    properties [PROP_NAME] =
        g_param_spec_string ("name",
                             "Name",
                             "The name of the account",
                             NULL,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_PATH] =
        g_param_spec_string ("path",
                             "Path",
                             "The path of the directory where files are located",
                             NULL,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_STATUS] =
        g_param_spec_enum ("status",
                           "Status",
                           "Status of the account",
                           CLOUD_TYPE_PROVIDERS_ACCOUNT_STATUS,
                           CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID,
                           (G_PARAM_READABLE |
                            G_PARAM_STATIC_STRINGS));
    properties [PROP_STATUS_DETAILS] =
        g_param_spec_string ("status-details",
                             "StatusDetails",
                             "The details of the account status",
                             NULL,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_ICON] =
        g_param_spec_object ("icon",
                             "Icon",
                             "The icon representing the account",
                             G_TYPE_ICON,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_MENU_MODEL] =
        g_param_spec_object ("menu-model",
                             "MenuModel",
                             "The menu model associated with the account",
                             G_TYPE_MENU_MODEL,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_ACTION_GROUP] =
        g_param_spec_object ("action-group",
                             "ActionGroup",
                             "The action group associated with the account and menu model",
                             G_TYPE_ACTION_GROUP,
                             (G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));

    g_object_class_install_properties (object_class,
                                       N_PROPS,
                                       properties);
}

static void
cloud_providers_account_init (CloudProvidersAccount *self)
{
}

/**
 * cloud_providers_account_get_name:
 * @self: A cloud provider account
 *
 * Get the name of the account
 *
 * Returns: The name of the cloud provider account
 */
const gchar*
cloud_providers_account_get_name (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->name;
}

/**
 * cloud_providers_account_get_status:
 * @self: A cloud provider account
 *
 * Get the status of the account
 *
 * Returns: The status of the cloud provider account
 */
CloudProvidersAccountStatus
cloud_providers_account_get_status (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID);

  return self->status;
}

/**
 * cloud_providers_account_get_status_details:
 * @self: A cloud provider account
 *
 * Get the status details of the account
 *
 * Returns: The status detail description of the cloud provider account
 */
const gchar*
cloud_providers_account_get_status_details (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->status_details;
}

/**
 * cloud_providers_account_get_icon:
 * @self: A cloud provider account
 *
 * Get the icon of the account
 *
 * Returns: (transfer none) : The icon of the cloud provider account
 */
GIcon*
cloud_providers_account_get_icon (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->icon;
}

/**
 * cloud_providers_account_get_menu_model:
 * @self: A cloud provider account
 *
 * Get the menu model exported for the account
 *
 * Returns: (transfer none) : The menu model exported by the cloud provider account
 */
GMenuModel*
cloud_providers_account_get_menu_model (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->menu_model;
}

/**
 * cloud_providers_account_get_action_group:
 * @self: A cloud provider account
 *
 * Get the action group exported in addition to the #GMenuModel from
 * cloud_providers_account_get_menu_model()
 *
 * Returns: (transfer none) : The action group exported by the cloud provider account
 */
GActionGroup*
cloud_providers_account_get_action_group (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->action_group;
}

/**
 * cloud_providers_account_get_path:
 * @self: A cloud provider account
 *
 * Get the directory path of the account
 *
 * Returns: The directory path of the cloud provider account
 */
const gchar *
cloud_providers_account_get_path (CloudProvidersAccount *self)
{
  g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT (self), NULL);

  return self->path;
}

07070100000017000081A400000000000000000000000165FAB13900000A28000000000000000000000000000000000000003400000000libcloudproviders-0.3.6/src/cloudprovidersaccount.h/* cloudprovidersaccount.h
 *
 * Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLOUD_PROVIDERS_ACCOUNT_H
#define CLOUD_PROVIDERS_ACCOUNT_H

#include <gio/gio.h>

G_BEGIN_DECLS

#define CLOUD_PROVIDERS_ACCOUNT_DBUS_IFACE "org.freedesktop.CloudProviders.Account"

/**
 * CloudProviderStatus:
 * @CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID: Set if the initial state of the account is unknown
 * @CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE: Set if the account is in idle mode
 * @CLOUD_PROVIDERS_ACCOUNT_STATUS_SYNCING: Set if the account is currently synchronizing data
 * @CLOUD_PROVIDERS_ACCOUNT_STATUS_ERROR: Set if an error occurred
 *
 * Enum values used to describe the sync status of a cloud providers account
 **/
typedef enum {
  CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID,
  CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE,
  CLOUD_PROVIDERS_ACCOUNT_STATUS_SYNCING,
  CLOUD_PROVIDERS_ACCOUNT_STATUS_ERROR
} CloudProvidersAccountStatus;

#define CLOUD_PROVIDERS_TYPE_ACCOUNT (cloud_providers_account_get_type())
G_DECLARE_FINAL_TYPE (CloudProvidersAccount, cloud_providers_account, CLOUD_PROVIDERS, ACCOUNT, GObject)

struct _CloudProvidersAccountClass
{
  GObjectClass parent_class;
};

CloudProvidersAccount *cloud_providers_account_new (GDBusProxy *proxy);

const gchar* cloud_providers_account_get_name (CloudProvidersAccount *self);
CloudProvidersAccountStatus cloud_providers_account_get_status (CloudProvidersAccount *self);
const gchar* cloud_providers_account_get_status_details (CloudProvidersAccount *self);
GIcon *cloud_providers_account_get_icon (CloudProvidersAccount *self);
GMenuModel *cloud_providers_account_get_menu_model (CloudProvidersAccount *self);
GActionGroup* cloud_providers_account_get_action_group (CloudProvidersAccount *self);
const gchar *cloud_providers_account_get_path (CloudProvidersAccount *self);
G_END_DECLS


#endif /* CLOUD_PROVIDERS_ACCOUNT_H */
07070100000018000081A400000000000000000000000165FAB13900004A10000000000000000000000000000000000000003C00000000libcloudproviders-0.3.6/src/cloudprovidersaccountexporter.c/* cloudprovidersaccountexporter.c
 *
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gio/gio.h>
#include "cloudprovidersaccount.h"
#include "cloudprovidersaccountexporter.h"
#include "cloudprovidersproviderexporter.h"
#include "cloudprovidersaccountexporterpriv.h"
#include "cloudprovidersproviderexporterpriv.h"
#include "cloudproviders-generated.h"
#include "enums.h"

struct _CloudProvidersAccountExporter
{
  GObject parent;

  gchar *bus_name;
  CloudProvidersDbusAccount *skeleton;

  GDBusConnection *bus; // unowned, owned by the provider
  gchar *object_path;
  gchar *name;
  gchar *path;
  CloudProvidersAccountStatus status;
  gchar *status_details;
  gchar *icon;
  GMenuModel *menu_model;
  GActionGroup *action_group;

  gint menu_model_export_id;
  gint action_group_export_id;
  CloudProvidersProviderExporter *provider;
};

G_DEFINE_TYPE (CloudProvidersAccountExporter, cloud_providers_account_exporter, G_TYPE_OBJECT)

enum
{
    PROP_0,
    PROP_NAME,
    PROP_BUS_NAME,
    PROP_PROVIDER,
    PROP_ICON,
    PROP_STATUS,
    PROP_STATUS_DETAILS,
    PROP_MENU_MODEL,
    PROP_ACTION_GROUP,
    PROP_PATH,
    N_PROPS
};

static GParamSpec *properties [N_PROPS];

/**
 * SECTION:cloudprovidersaccountexporter
 * @title: CloudProvidersAccountExporter
 * @short_description: Base object for representing a cloud providers account
 * @include: src/cloudprovidersaccountexporter.h
 */

static void
export_menu_model (CloudProvidersAccountExporter *self)
{
    g_autoptr(GError) error = NULL;

    self->menu_model_export_id = g_dbus_connection_export_menu_model (self->bus,
                                                                      self->object_path,
                                                                      self->menu_model,
                                                                      &error);
    if (self->menu_model_export_id == 0)
      g_warning ("Menu export failed: %s", error->message);
}

static void
unexport_menu_model (CloudProvidersAccountExporter *self)
{
    if(self->menu_model_export_id != 0)
    {
        g_dbus_connection_unexport_menu_model(self->bus, self->menu_model_export_id);
        self->menu_model_export_id = 0;
    }
}

static void
export_action_group (CloudProvidersAccountExporter *self)
{
    g_autoptr(GError) error = NULL;

    self->action_group_export_id = g_dbus_connection_export_action_group (self->bus,
                                                                          self->object_path,
                                                                          self->action_group,
                                                                          &error);
    if (self->action_group_export_id == 0)
        g_warning ("Action export failed: %s", error->message);
}

static void
unexport_action_group (CloudProvidersAccountExporter *self)
{
    if (self->action_group_export_id != 0)
    {
        g_dbus_connection_unexport_action_group(self->bus, self->action_group_export_id);
        self->action_group_export_id = 0;
    }
}

const gchar *
cloud_providers_account_exporter_get_object_path (CloudProvidersAccountExporter *self)
{
    g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self), NULL);

    return self->object_path;
}

const gchar *
cloud_providers_account_exporter_get_bus_name (CloudProvidersAccountExporter *self)
{
    g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self), NULL);

    return self->bus_name;
}

CloudProvidersDbusAccount*
cloud_providers_account_exporter_get_skeleton (CloudProvidersAccountExporter *self)
{
    g_return_val_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self), NULL);

    return self->skeleton;
}

/**
 * cloud_providers_account_exporter_new:
 * @provider: The provider to which it will be associated.
 * @bus_name: A unique name for the account
 *               must be a valid DBus object name
 *
 * Create a new #CloudProvidersAccountExporter object
 */
CloudProvidersAccountExporter*
cloud_providers_account_exporter_new (CloudProvidersProviderExporter *provider,
                                      const gchar                    *bus_name)
{
    CloudProvidersAccountExporter *self;

    self = g_object_new (CLOUD_PROVIDERS_TYPE_ACCOUNT_EXPORTER,
                         "provider", provider,
                         "bus-name", bus_name,
                         NULL);
    return self;
}

static void
cloud_providers_account_exporter_get_property (GObject    *object,
                                               guint       prop_id,
                                               GValue     *value,
                                               GParamSpec *pspec)
{
    CloudProvidersAccountExporter *self = CLOUD_PROVIDERS_ACCOUNT_EXPORTER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_value_set_string (value, self->name);
        }
        break;

        case PROP_BUS_NAME:
        {
            g_value_set_string (value, self->bus_name);
        }
        break;

        case PROP_PROVIDER:
        {
            g_value_set_object (value, self->provider);
        }
        break;

        case PROP_STATUS:
        {
            g_value_set_enum (value, self->status);
        }
        break;

        case PROP_STATUS_DETAILS:
        {
            g_value_set_string (value, self->status_details);
        }
        break;

        case PROP_ICON:
        {
            g_autoptr (GIcon) icon = NULL;

            icon = g_icon_new_for_string (self->icon, NULL);
            g_value_take_object (value, g_icon_new_for_string (self->icon, NULL));
        }
        break;

        case PROP_PATH:
        {
            g_value_set_string (value, self->path);
        }
        break;

        case PROP_ACTION_GROUP:
        {
            g_value_set_object (value, self->action_group);
        }
        break;

        case PROP_MENU_MODEL:
        {
            g_value_set_object (value, self->menu_model);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }

    }
}

static void
cloud_providers_account_exporter_set_property (GObject      *object,
                                               guint         prop_id,
                                               const GValue *value,
                                               GParamSpec   *pspec)
{
    CloudProvidersAccountExporter *self = CLOUD_PROVIDERS_ACCOUNT_EXPORTER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_free (self->name);
            self->name = g_value_dup_string (value);
            cloud_providers_dbus_account_set_name (self->skeleton, self->name);
        }
        break;

        case PROP_BUS_NAME:
        {
            g_return_if_fail (self->bus_name == NULL);
            self->bus_name = g_value_dup_string (value);
        }
        break;

        case PROP_PROVIDER:
        {
            g_return_if_fail (self->provider == NULL);
            g_set_weak_pointer (&self->provider, g_value_get_object (value));
        }
        break;

        case PROP_STATUS:
        {
            self->status = g_value_get_enum (value);
            cloud_providers_dbus_account_set_status (self->skeleton, self->status);
        }
        break;

        case PROP_STATUS_DETAILS:
        {
            g_free (self->status_details);
            self->status_details = g_value_dup_string (value);
            cloud_providers_dbus_account_set_status_details (self->skeleton, self->status_details);
        }
        break;

        case PROP_ICON:
        {
            g_free (self->icon);
            self->icon = g_icon_to_string (g_value_get_object (value));
            cloud_providers_dbus_account_set_icon (self->skeleton,
                                                   self->icon);
        }
        break;

        case PROP_PATH:
        {
            g_free (self->path);
            self->path = g_value_dup_string (value);
            cloud_providers_dbus_account_set_path (self->skeleton, self->path);
        }
        break;

        case PROP_ACTION_GROUP:
        {
            cloud_providers_account_exporter_set_action_group (self, (GActionGroup *) g_value_get_object (value));
        }
        break;

        case PROP_MENU_MODEL:
        {
            cloud_providers_account_exporter_set_menu_model (self, (GMenuModel *) g_value_get_object (value));
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }
    }
}

void
cloud_providers_account_exporter_set_name (CloudProvidersAccountExporter *self,
                                           const gchar                   *name)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_object_set (self, "name", name, NULL);
}

void
cloud_providers_account_exporter_set_status (CloudProvidersAccountExporter *self,
                                             CloudProvidersAccountStatus    status)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_object_set (self, "status", status, NULL);
}

void
cloud_providers_account_exporter_set_status_details (CloudProvidersAccountExporter *self,
                                                     const gchar                   *status_details)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_object_set (self, "status-details", status_details, NULL);
}

void
cloud_providers_account_exporter_set_icon (CloudProvidersAccountExporter *self,
                                           GIcon                         *icon)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_object_set (self, "icon", icon, NULL);
}

/**
 * cloud_providers_account_exporter_set_menu_model:
 * @self: The account
 * @menu_model: The menu model to export
 *
 * One of the benefits of the integration is to display a menu with available
 * options for an account. Use this function to export a GMenuModel menu to be
 * displayed by the chosen integration by the desktop environment or application.
 */
void
cloud_providers_account_exporter_set_menu_model (CloudProvidersAccountExporter *self,
                                                 GMenuModel                    *menu_model)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_return_if_fail (self->menu_model == NULL);

    if (g_set_object (&self->menu_model, menu_model)) {
        export_menu_model (self);
    }
}

/**
 * cloud_providers_account_exporter_set_action_group:
 * @self: The cloud provider
 * @action_group: The GActionGroup to be used by the menu exported by cloud_providers_account_exporter_export_menu
 *
 * In order for a menu exported with cloud_providers_account_exporter_export_menu to receive events
 * that will eventually call your callbacks, it needs the corresponding GActionGroup.
 * Use this function to export it.
 */
void
cloud_providers_account_exporter_set_action_group (CloudProvidersAccountExporter *self,
                                                   GActionGroup                  *action_group)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_return_if_fail (self->action_group == NULL);

    if (g_set_object (&self->action_group, action_group)) {
        export_action_group (self);
    }
}

void
cloud_providers_account_exporter_set_path (CloudProvidersAccountExporter *self,
                                           const gchar                   *path)
{
    g_return_if_fail (CLOUD_PROVIDERS_IS_ACCOUNT_EXPORTER (self));

    g_object_set (self, "path", path, NULL);
}

static void
cloud_providers_account_exporter_dispose (GObject *object)
{
    CloudProvidersAccountExporter *self = (CloudProvidersAccountExporter *)object;
    unexport_menu_model (self);
    unexport_action_group (self);

    g_clear_object (&self->skeleton);
    g_clear_object (&self->action_group);
    g_clear_object (&self->menu_model);
    g_clear_weak_pointer (&self->provider);

    G_OBJECT_CLASS (cloud_providers_account_exporter_parent_class)->dispose (object);
}

static void
cloud_providers_account_exporter_finalize (GObject *object)
{
    CloudProvidersAccountExporter *self = (CloudProvidersAccountExporter *)object;

    g_clear_pointer (&self->bus_name, g_free);
    g_clear_pointer (&self->name, g_free);
    g_clear_pointer (&self->object_path, g_free);
    g_clear_pointer (&self->status_details, g_free);
    g_clear_pointer (&self->path, g_free);
    g_clear_pointer (&self->icon, g_free);

    G_OBJECT_CLASS (cloud_providers_account_exporter_parent_class)->finalize (object);
}

static void
cloud_providers_account_exporter_constructed (GObject *object)
{
    CloudProvidersAccountExporter *self = CLOUD_PROVIDERS_ACCOUNT_EXPORTER (object);
    const gchar *provider_object_path;

    self->bus = cloud_providers_provider_exporter_get_bus (self->provider);
    provider_object_path = cloud_providers_provider_exporter_get_object_path (self->provider);
    self->object_path = g_strconcat (provider_object_path, "/", self->bus_name, NULL);
    cloud_providers_provider_exporter_add_account (self->provider, self);
}

static void
cloud_providers_account_exporter_init (CloudProvidersAccountExporter *self)
{
    self->skeleton = cloud_providers_dbus_account_skeleton_new ();
}

static void
cloud_providers_account_exporter_class_init (CloudProvidersAccountExporterClass *klass)
{
    GObjectClass *object_class = G_OBJECT_CLASS (klass);

    object_class->get_property = cloud_providers_account_exporter_get_property;
    object_class->set_property = cloud_providers_account_exporter_set_property;
    object_class->constructed = cloud_providers_account_exporter_constructed;
    object_class->dispose = cloud_providers_account_exporter_dispose;
    object_class->finalize = cloud_providers_account_exporter_finalize;

    properties [PROP_NAME] =
        g_param_spec_string ("name",
                             "Name",
                             "The name of the account",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_NAME,
                                     properties [PROP_NAME]);
    properties [PROP_BUS_NAME] =
        g_param_spec_string ("bus-name",
                             "BusName",
                             "The bus name of the account",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS|
                              G_PARAM_CONSTRUCT_ONLY));
    g_object_class_install_property (object_class, PROP_BUS_NAME,
                                     properties [PROP_BUS_NAME]);
    properties [PROP_PROVIDER] =
        g_param_spec_object ("provider",
                             "Provider",
                             "The provider associated with the account",
                             CLOUD_PROVIDERS_TYPE_PROVIDER_EXPORTER,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS |
                              G_PARAM_CONSTRUCT_ONLY));
    g_object_class_install_property (object_class, PROP_PROVIDER,
                                     properties [PROP_PROVIDER]);
    properties [PROP_PATH] =
        g_param_spec_string ("path",
                             "Path",
                             "The path of the directory where files are located",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_PATH,
                                     properties [PROP_PATH]);
    properties [PROP_STATUS] =
        g_param_spec_enum ("status",
                          "Status",
                          "Status of the account",
                          CLOUD_TYPE_PROVIDERS_ACCOUNT_STATUS,
                          CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID,
                          (G_PARAM_READWRITE |
                           G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_STATUS,
                                     properties [PROP_STATUS]);
    properties [PROP_STATUS_DETAILS] =
        g_param_spec_string ("status-details",
                             "StatusDetails",
                             "The details of the account status",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_STATUS_DETAILS,
                                     properties [PROP_STATUS_DETAILS]);
    properties [PROP_ICON] =
        g_param_spec_object ("icon",
                             "Icon",
                             "The icon representing the account",
                             G_TYPE_ICON,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_ICON,
                                     properties [PROP_ICON]);
    properties [PROP_MENU_MODEL] =
        g_param_spec_object ("menu-model",
                             "MenuModel",
                             "The menu model associated with the account",
                             G_TYPE_MENU_MODEL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_MENU_MODEL,
                                     properties [PROP_MENU_MODEL]);
    properties [PROP_ACTION_GROUP] =
        g_param_spec_object ("action-group",
                             "ActionGroup",
                             "The action group associated with the account and menu model",
                             G_TYPE_ACTION_GROUP,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    g_object_class_install_property (object_class, PROP_ACTION_GROUP,
                                     properties [PROP_ACTION_GROUP]);
}

07070100000019000081A400000000000000000000000165FAB13900000AF1000000000000000000000000000000000000003C00000000libcloudproviders-0.3.6/src/cloudprovidersaccountexporter.h/* cloudprovidersaccountexporter.h
 *
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLOUD_PROVIDERS_ACCOUNT_EXPORTER_H
#define CLOUD_PROVIDERS_ACCOUNT_EXPORTER_H

#include <gio/gio.h>
#include "cloudprovidersaccount.h"

G_BEGIN_DECLS

#define CLOUD_PROVIDERS_TYPE_ACCOUNT_EXPORTER (cloud_providers_account_exporter_get_type())
G_DECLARE_FINAL_TYPE (CloudProvidersAccountExporter, cloud_providers_account_exporter, CLOUD_PROVIDERS, ACCOUNT_EXPORTER, GObject)

typedef struct _CloudProvidersProviderExporter CloudProvidersProviderExporter;

struct _CloudProvidersAccountExporterClass
{
  GObjectClass parent_class;
};

CloudProvidersAccountExporter*
cloud_providers_account_exporter_new (CloudProvidersProviderExporter *provider,
                                      const gchar                    *bus_name);

void
cloud_providers_account_exporter_set_name (CloudProvidersAccountExporter *self,
                                           const gchar                    *name);

void
cloud_providers_account_exporter_set_status (CloudProvidersAccountExporter *self,
                                             CloudProvidersAccountStatus    status);

void
cloud_providers_account_exporter_set_status_details (CloudProvidersAccountExporter *self,
                                                     const gchar                   *status_details);

void
cloud_providers_account_exporter_set_icon (CloudProvidersAccountExporter *self,
                                           GIcon                          *icon);

void
cloud_providers_account_exporter_set_menu_model (CloudProvidersAccountExporter *self,
                                                 GMenuModel                     *menu_model);

void
cloud_providers_account_exporter_set_action_group (CloudProvidersAccountExporter *self,
                                                   GActionGroup                   *action_group);

void
cloud_providers_account_exporter_set_path (CloudProvidersAccountExporter *self,
                                           const gchar                    *path);

G_END_DECLS

#endif /* CLOUD_PROVIDERS_ACCOUNT_EXPORTER_H */
0707010000001A000081A400000000000000000000000165FAB1390000051A000000000000000000000000000000000000004000000000libcloudproviders-0.3.6/src/cloudprovidersaccountexporterpriv.h/* cloudprovidersaccountexporterpriv.h
 *
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLOUD_PROVIDERS_ACCOUNT_EXPORTER_PRIV_H
#define CLOUD_PROVIDERS_ACCOUNT_EXPORTER_PRIV_H

#include <gio/gio.h>
#include "cloudprovidersaccountexporter.h"
#include "cloudproviders-generated.h"
G_BEGIN_DECLS

CloudProvidersDbusAccount*
cloud_providers_account_exporter_get_skeleton (CloudProvidersAccountExporter *self);
const gchar *
cloud_providers_account_exporter_get_object_path (CloudProvidersAccountExporter *self);
const gchar *
cloud_providers_account_exporter_get_bus_name (CloudProvidersAccountExporter *self);

G_END_DECLS

#endif
0707010000001B000081A400000000000000000000000165FAB13900003477000000000000000000000000000000000000003600000000libcloudproviders-0.3.6/src/cloudproviderscollector.c/* cloudproviders.c
 *
 * Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "cloudproviderscollector.h"
#include "cloudprovidersaccount.h"
#include "cloudprovidersprovider.h"
#include "cloudproviders-generated.h"
#include <glib.h>
#include <glib/gprintf.h>
#include <gio/gio.h>

#define KEY_FILE_GROUP "Cloud Providers"
#define XDG_DESKTOP_IMPLEMENTS "org.freedesktop.CloudProviders"

struct _CloudProvidersCollector
{
    GObject parent;

    GList *providers;
    GHashTable *providers_bus_names;
    GDBusConnection *bus;
    GCancellable *cancellable;
    GList *monitors;
};

G_DEFINE_TYPE (CloudProvidersCollector, cloud_providers_collector, G_TYPE_OBJECT)

/**
 * SECTION:cloudproviderscollector
 * @title: CloudProvidersCollector
 * @short_description: Singleton for tracking all providers.
 * @include: src/cloudproviders.h
 *
 * #CloudProvidersCollector is a singleton to track all the changes in all providers.
 * Using a #CloudProvidersCollector you can implement integration for all of them at once
 * and represent them in the UI, track new providers added or removed and their
 * status.
 */

enum
{
  PROVIDERS_CHANGED,
  LAST_SIGNAL
};

static guint signals [LAST_SIGNAL];

static void
update_cloud_providers (CloudProvidersCollector *self);

static void
on_bus_acquired (GObject      *source_object,
                 GAsyncResult *res,
                 gpointer      user_data)
{
    CloudProvidersCollector *self;
    g_autoptr(GError) error = NULL;
    GDBusConnection *connection;

    connection = g_bus_get_finish (res, &error);
    if (error != NULL)
    {
        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
            g_debug ("Error acquiring bus for cloud providers: %s", error->message);
        return;
    }

    /* The CloudProvidersCollector could be destroyed before arriving here */
    self = CLOUD_PROVIDERS_COLLECTOR (user_data);
    self->bus = g_steal_pointer (&connection);
    update_cloud_providers (self);
}

static void
cloud_providers_collector_dispose (GObject *object)
{
    CloudProvidersCollector *self = (CloudProvidersCollector *)object;
    GList *l;

    g_cancellable_cancel (self->cancellable);
    g_clear_object (&self->cancellable);
    for (l = self->monitors; l != NULL; l = l->next)
    {
        g_signal_handlers_disconnect_by_data (G_OBJECT (l->data), self);
    }
    for (l = self->providers; l != NULL; l = l->next)
    {
        g_signal_handlers_disconnect_by_data (G_OBJECT (l->data), self);
    }
    g_clear_pointer (&self->providers_bus_names, g_hash_table_unref);
    g_list_free_full (self->providers, g_object_unref);
    self->providers = NULL;
    g_list_free_full (self->monitors, g_object_unref);
    self->monitors = NULL;
    g_clear_object (&self->bus);

    G_OBJECT_CLASS (cloud_providers_collector_parent_class)->dispose (object);
}

static void
cloud_providers_collector_class_init (CloudProvidersCollectorClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  object_class->dispose = cloud_providers_collector_dispose;

  /**
   * CloudProviderCollector::providers-changed
   *
   * This signal is emitted by the amount of providers changed.
   */
  signals [PROVIDERS_CHANGED] = g_signal_new ("providers-changed",
                                              G_TYPE_FROM_CLASS (klass),
                                              G_SIGNAL_RUN_LAST,
                                              0,
                                              NULL,
                                              NULL,
                                              g_cclosure_marshal_generic,
                                              G_TYPE_NONE,
                                              0);
}

static void
cloud_providers_collector_init (CloudProvidersCollector *self)
{
    self->cancellable = g_cancellable_new ();
    self->providers_bus_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

    g_bus_get (G_BUS_TYPE_SESSION,
               self->cancellable,
               on_bus_acquired,
               self);
}

/**
 * cloud_providers_collector_get_providers
 * @self: A CloudProvidersCollector
 * Returns: (element-type CloudProviders.Provider) (transfer none): A GList* of #CloudProvidersProvider objects.
 */
GList*
cloud_providers_collector_get_providers (CloudProvidersCollector *self)
{
  return self->providers;
}

static void
on_provider_removed (CloudProvidersCollector *self)
{
    update_cloud_providers (self);
}

static void
add_cloud_provider (CloudProvidersCollector *self,
                    const gchar             *bus_name,
                    const gchar             *object_path)
{
    g_autoptr(CloudProvidersProvider) provider = NULL;

    provider = cloud_providers_provider_new (bus_name, object_path);
    if (g_hash_table_contains (self->providers_bus_names, bus_name))
    {
        g_debug ("Skipped duplicate provider: %s %s\n", bus_name, object_path);
        return;
    }

    self->providers = g_list_append (self->providers, g_object_ref (provider));
    g_hash_table_add (self->providers_bus_names, g_strdup (bus_name));
    g_signal_connect_swapped (provider, "removed",
                              G_CALLBACK (on_provider_removed), self);

    g_debug ("Client loading provider: %s %s\n", bus_name, object_path);
}

static void
load_cloud_provider_from_desktop_file (CloudProvidersCollector *self,
                                       GFile                   *file)
{
    g_autoptr(GKeyFile) key_file = NULL;
    g_autoptr(GError) error = NULL;
    g_autofree gchar *path = NULL;
    g_auto(GStrv) implements = NULL;
    g_autofree gchar *bus_name = NULL;
    g_autofree gchar *object_path = NULL;

    path = g_file_get_path (file);
    if (!g_str_has_suffix (path, ".desktop"))
    {
        return;
    }

    key_file = g_key_file_new ();
    if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error))
    {
        g_warning ("Error loading .desktop file at %s: %s", path, error->message);
        return;
    }

    implements = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, "Implements", NULL, &error);
    if (implements == NULL)
    {
        if (!g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
        {
            g_warning ("Error loading Implements key from %s: %s", path, error->message);
        }

        return;
    }

    if (!g_strv_contains((const gchar * const *) implements, XDG_DESKTOP_IMPLEMENTS))
    {
        return;
    }

    bus_name = g_key_file_get_string (key_file, XDG_DESKTOP_IMPLEMENTS, "BusName", NULL);
    object_path = g_key_file_get_string (key_file, XDG_DESKTOP_IMPLEMENTS, "ObjectPath", NULL);

    if (!bus_name || !object_path)
    {
        g_warning ("Unable to find BusName or ObjectPath keys in "XDG_DESKTOP_IMPLEMENTS" section from %s", path);
        return;
    }

    add_cloud_provider (self, bus_name, object_path);
}

static void
load_cloud_provider_from_key_file (CloudProvidersCollector *self,
                                   GFile                   *file)
{
    g_autoptr(GKeyFile) key_file = g_key_file_new ();
    g_autofree gchar *path = NULL;
    GError *error = NULL;
    g_autofree gchar *bus_name = NULL;
    g_autofree gchar *object_path = NULL;
    CloudProvidersProvider *provider;

    path = g_file_get_path (file);
    g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error);
    if (error != NULL)
    {
        g_debug ("Error while loading cloud provider key file at %s with error %s", path, error->message);
        return;
    }

    if (!g_key_file_has_group (key_file, KEY_FILE_GROUP))
    {
        g_debug ("Error while loading cloud provider key file at %s with error %s", path, error->message);
        return;
    }

    bus_name = g_key_file_get_string (key_file, KEY_FILE_GROUP, "BusName", &error);
    if (error != NULL)
    {
        g_debug ("Error while loading cloud provider key file at %s with error %s", path, error->message);
        return;
    }
    object_path = g_key_file_get_string (key_file, KEY_FILE_GROUP, "ObjectPath", &error);
    if (error != NULL)
    {
        g_debug ("Error while loading cloud provider key file at %s with error %s", path, error->message);
        return;
    }

    provider = cloud_providers_provider_new (bus_name, object_path);
    self->providers = g_list_append (self->providers, provider);
    g_signal_connect_swapped (provider, "removed",
                              G_CALLBACK (on_provider_removed), self);

    g_debug("Client loading provider: %s %s\n", bus_name, object_path);
}

static void
on_providers_file_changed (CloudProvidersCollector *self)
{
    update_cloud_providers (self);
}

static void
load_cloud_providers (CloudProvidersCollector *self)
{
    const gchar* const *data_dirs;
    const gchar *data_subdirs[] = {"applications", "cloud-providers"};
    guint i;
    gsize j;

    data_dirs = g_get_system_data_dirs ();
    for (i = 0; data_dirs[i] != NULL; i++)
    {
        for (j = 0; j < G_N_ELEMENTS (data_subdirs); j++)
        {
            g_autoptr (GFile) directory_file = NULL;
            g_autoptr (GFileInfo) info = NULL;
            g_autoptr (GFileEnumerator) file_enumerator = NULL;
            g_autoptr (GFileMonitor) monitor = NULL;
            g_autoptr (GError) error = NULL;

            directory_file = g_file_new_build_filename (data_dirs[i], data_subdirs[j], NULL);
            monitor = g_file_monitor (directory_file, G_FILE_MONITOR_WATCH_MOVES,
                                      self->cancellable, NULL);
            g_signal_connect_swapped (monitor, "changed", G_CALLBACK (on_providers_file_changed), self);
            self->monitors = g_list_append (self->monitors, g_steal_pointer (&monitor));
            file_enumerator = g_file_enumerate_children (directory_file,
                                                         "standard::name,standard::type",
                                                         G_FILE_QUERY_INFO_NONE,
                                                         NULL,
                                                         &error);
            if (error)
            {
                g_clear_error (&error);
                continue;
            }

            info = g_file_enumerator_next_file (file_enumerator, NULL, &error);
            if (error)
            {
                g_autofree gchar *directory_path = g_file_get_path (directory_file);
                g_warning ("Error while enumerating file %s error: %s\n", directory_path, error->message);
                g_clear_error (&error);
                continue;
            }

            while (info != NULL && error == NULL)
            {
                g_autoptr(GFile) child = g_file_enumerator_get_child (file_enumerator, info);
                if (strcmp (data_subdirs[j], "applications") == 0)
                {
                    load_cloud_provider_from_desktop_file (self, child);
                }
                else
                {
                    load_cloud_provider_from_key_file (self, child);
                }

                g_clear_object (&info);
                info = g_file_enumerator_next_file (file_enumerator, NULL, &error);
            }
        }
    }
}

static void
update_cloud_providers (CloudProvidersCollector *self)
{
    GList *l;

    g_cancellable_cancel (self->cancellable);
    g_clear_object (&self->cancellable);
    self->cancellable = g_cancellable_new ();
    for (l = self->monitors; l != NULL; l = l->next)
    {
        g_signal_handlers_disconnect_by_data (G_OBJECT (l->data), self);
    }
    for (l = self->providers; l != NULL; l = l->next)
    {
        g_signal_handlers_disconnect_by_data (G_OBJECT (l->data), self);
    }
    g_hash_table_remove_all (self->providers_bus_names);
    g_list_free_full (self->providers, g_object_unref);
    g_list_free_full (self->monitors, g_object_unref);
    self->providers = NULL;
    self->monitors = NULL;

    load_cloud_providers (self);

    g_signal_emit_by_name (G_OBJECT (self), "providers-changed");
}

static gpointer
singleton_creation_thread (gpointer data)
{
    return g_object_new (CLOUD_PROVIDERS_TYPE_COLLECTOR, NULL);
}

/**
 * cloud_providers_collector_dup_singleton:
 * Main object to track changes in all providers.
 *
 * Returns: (transfer full): A manager singleton
 */
CloudProvidersCollector *
cloud_providers_collector_dup_singleton (void)
{
    static GOnce collector_singleton = G_ONCE_INIT;
    CloudProvidersCollector *self;

    g_once (&collector_singleton, singleton_creation_thread, NULL);

    self = CLOUD_PROVIDERS_COLLECTOR (collector_singleton.retval);
    return g_object_ref (self);
}

0707010000001C000081A400000000000000000000000165FAB139000005D2000000000000000000000000000000000000003600000000libcloudproviders-0.3.6/src/cloudproviderscollector.h/* cloudproviderscollector.h
 *
 * Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef CLOUD_PROVIDERS_COLLECTOR_H
#define CLOUD_PROVIDERS_COLLECTOR_H

#include <gio/gio.h>
#include "cloudprovidersaccount.h"

G_BEGIN_DECLS

#define CLOUD_PROVIDERS_TYPE_COLLECTOR (cloud_providers_collector_get_type())
G_DECLARE_FINAL_TYPE (CloudProvidersCollector, cloud_providers_collector, CLOUD_PROVIDERS, COLLECTOR, GObject)

struct _CloudProvidersCollectorClass
{
  GObjectClass parent_class;
};

CloudProvidersCollector *cloud_providers_collector_dup_singleton (void);
void cloud_providers_collector_update (CloudProvidersCollector *self);
GList *cloud_providers_collector_get_providers (CloudProvidersCollector *self);
G_END_DECLS

#endif /* CLOUD_PROVIDERS_COLLECTOR_H */
0707010000001D000081A400000000000000000000000165FAB13900003839000000000000000000000000000000000000003500000000libcloudproviders-0.3.6/src/cloudprovidersprovider.c/* cloudprovidersprovider.c
 *
 * Copyright (C) 2017 Carlos Soriano <csoriano@gnome.org>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gio/gio.h>

#include "cloudprovidersprovider.h"
#include "cloudprovidersaccount.h"
#include "cloudproviders-generated.h"

struct _CloudProvidersProvider
{
    GObject parent_instance;

    GDBusObjectManager *manager;
    gchar *name;
    GList *accounts;
    gchar *manager_bus_name;
    gchar *manager_object_path;

    GDBusConnection *bus;
    CloudProvidersDbusProvider *proxy;
    GCancellable *cancellable;
};

G_DEFINE_TYPE (CloudProvidersProvider, cloud_providers_provider, G_TYPE_OBJECT)

/**
 * SECTION:cloudprovidersprovider
 * @title: CloudProvidersProvider
 * @short_description: Base object for representing a single provider for clients.
 * @include: src/cloudprovidersprovider.h
 *
 * #CloudProvidersProvider is the basic object object for client implementers
 * that contains the properties of the provider such as name, and the accounts
 * associated with it.
 */

enum
{
    PROP_0,
    PROP_NAME,
    N_PROPS
};

enum
{
    ACCOUNTS_CHANGED,
    REMOVED,
    LAST_SIGNAL
};

static guint signals [LAST_SIGNAL];
static GParamSpec *properties [N_PROPS];

static void
on_name_changed (CloudProvidersProvider *self);
static void
on_cloud_providers_object_manager_object_added (GDBusObjectManager *manager,
                                                GDBusObject        *object,
                                                gpointer            user_data);

static void
on_cloud_providers_object_manager_object_removed (GDBusObjectManager *manager,
                                                  GDBusObject        *object,
                                                  gpointer            user_data);

static void
on_cloud_providers_object_manager_name_owner_changed (GObject    *object,
                                                      GParamSpec *pspec,
                                                      gpointer    user_data);

CloudProvidersProvider *
cloud_providers_provider_new (const gchar *bus_name,
                              const gchar *object_path)
{
    CloudProvidersProvider *self;

    g_return_val_if_fail (bus_name != NULL, NULL);
    g_return_val_if_fail (object_path != NULL, NULL);

    self = g_object_new (CLOUD_PROVIDERS_TYPE_PROVIDER, NULL);
    self->manager_bus_name = g_strdup (bus_name);
    self->manager_object_path = g_strdup (object_path);

    return self;
}

static void
cloud_providers_provider_dispose (GObject *object)
{
    CloudProvidersProvider *self = (CloudProvidersProvider *)object;

    g_cancellable_cancel (self->cancellable);
    g_clear_object (&self->cancellable);

    g_list_free_full (self->accounts, g_object_unref);
    self->accounts = NULL;

    if (self->proxy)
        g_signal_handlers_disconnect_by_func (self->proxy, G_CALLBACK (on_name_changed), self);
    g_clear_object (&self->proxy);

    if (self->manager)
    {
        g_signal_handlers_disconnect_by_func (self->manager,
                                              G_CALLBACK (on_cloud_providers_object_manager_name_owner_changed),
                                              self);
        g_signal_handlers_disconnect_by_func (self->manager,
                                              G_CALLBACK (on_cloud_providers_object_manager_object_added),
                                              self);
        g_signal_handlers_disconnect_by_func (self->manager,
                                              G_CALLBACK (on_cloud_providers_object_manager_object_removed),
                                              self);
    }

    g_clear_object (&self->manager);
    g_clear_object (&self->bus);

    G_OBJECT_CLASS (cloud_providers_provider_parent_class)->dispose (object);
}

static void
cloud_providers_provider_finalize (GObject *object)
{
    CloudProvidersProvider *self = (CloudProvidersProvider *)object;

    g_clear_pointer (&self->name, g_free);
    g_clear_pointer (&self->manager_bus_name, g_free);
    g_clear_pointer (&self->manager_object_path, g_free);

    G_OBJECT_CLASS (cloud_providers_provider_parent_class)->finalize (object);
}

static void
cloud_providers_provider_get_property (GObject    *object,
                                       guint       prop_id,
                                       GValue     *value,
                                       GParamSpec *pspec)
{
    CloudProvidersProvider *self = CLOUD_PROVIDERS_PROVIDER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_value_set_string (value, self->name);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }

    }
}

static void
cloud_providers_provider_set_property (GObject      *object,
                                       guint         prop_id,
                                       const GValue *value,
                                       GParamSpec   *pspec)
{
    CloudProvidersProvider *self = CLOUD_PROVIDERS_PROVIDER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_free (self->name);
            self->name = g_value_dup_string (value);
            g_object_notify_by_pspec (object, properties[PROP_NAME]);
        }
        break;

        break;
        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }

    }
}

static void
cloud_providers_provider_class_init (CloudProvidersProviderClass *klass)
{
    GObjectClass *object_class = G_OBJECT_CLASS (klass);

    object_class->dispose = cloud_providers_provider_dispose;
    object_class->finalize = cloud_providers_provider_finalize;
    object_class->get_property = cloud_providers_provider_get_property;
    object_class->set_property = cloud_providers_provider_set_property;

    properties [PROP_NAME] =
        g_param_spec_string ("name",
                             "Name",
                             "Name of the provider",
                             NULL,
                             (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
    g_object_class_install_properties (object_class,
                                       N_PROPS,
                                       properties);

  /**
   * CloudProviderProvider::accounts-changed
   *
   * This signal is emitted by a provider if the number of accounts changed.
   */
  signals [ACCOUNTS_CHANGED] =
    g_signal_new ("accounts-changed",
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
                  0,
                  NULL,
                  NULL,
                  g_cclosure_marshal_generic,
                  G_TYPE_NONE,
                  0);
  /**
   * CloudProviderProvider::removed
   *
   * This signal is emitted by a provider when the provider is removed in DBUS.
   */
  signals [REMOVED] =
    g_signal_new ("removed",
                  G_TYPE_FROM_CLASS (klass),
                  G_SIGNAL_RUN_LAST,
                  0,
                  NULL,
                  NULL,
                  g_cclosure_marshal_generic,
                  G_TYPE_NONE,
                  0);
}

static void
update_cloud_providers_accounts (CloudProvidersProvider *self)
{
    GList *objects;
    GList *l;

    g_list_free_full (self->accounts, g_object_unref);
    self->accounts = NULL;
    objects = g_dbus_object_manager_get_objects (self->manager);
    if (objects == NULL)
    {
        if (self->name != NULL)
        {
            g_debug ("Provider accounts not ready server side for %s\n", self->name);
        }
        else
        {
            g_debug ("Provider accounts not ready server side for %p\n", self);
        }
        return;
    }

    for (l = objects; l != NULL; l = l->next)
    {
        CloudProvidersDbusObject *object;
        GDBusInterface *interface;

        object = CLOUD_PROVIDERS_DBUS_OBJECT (l->data);
        interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object),
                                                 CLOUD_PROVIDERS_PROVIDER_DBUS_IFACE);
        if (interface != NULL)
        {
            self->proxy = cloud_providers_dbus_object_get_provider (object);
            g_signal_connect_swapped (self->proxy, "notify::name", G_CALLBACK (on_name_changed), self);
            on_name_changed (self);
            g_object_unref (interface);

            continue;
        }
        interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object),
                                                 CLOUD_PROVIDERS_ACCOUNT_DBUS_IFACE);
        if (interface != NULL)
        {
            CloudProvidersAccount *account;

            account = cloud_providers_account_new (G_DBUS_PROXY (cloud_providers_dbus_object_peek_account (object)));

            self->accounts = g_list_append (self->accounts, account);
            g_object_unref (interface);

            continue;
        }
    }

    g_list_free_full (objects, g_object_unref);

    g_signal_emit_by_name (G_OBJECT (self), "accounts-changed", NULL);
}

static void
on_cloud_providers_object_manager_object_added (GDBusObjectManager *manager,
                                                GDBusObject        *object,
                                                gpointer            user_data)
{
    CloudProvidersProvider *self;

    self = CLOUD_PROVIDERS_PROVIDER (user_data);
    update_cloud_providers_accounts (self);
}

static void
on_cloud_providers_object_manager_object_removed (GDBusObjectManager *manager,
                                                  GDBusObject        *object,
                                                  gpointer            user_data)
{
    CloudProvidersProvider *self;

    self = CLOUD_PROVIDERS_PROVIDER (user_data);
    update_cloud_providers_accounts (self);
}

static void
on_cloud_providers_object_manager_name_owner_changed (GObject    *object,
                                                      GParamSpec *pspec,
                                                      gpointer    user_data)
{
    CloudProvidersProvider *self;

    self = CLOUD_PROVIDERS_PROVIDER (user_data);
    g_signal_emit_by_name (G_OBJECT (self), "removed", NULL);
}

static void
on_name_changed (CloudProvidersProvider *self)
{
    g_free (self->name);
    self->name = cloud_providers_dbus_provider_dup_name (self->proxy);
    if (self->name == NULL)
    {
        g_debug ("Provider name not ready for %p\n", self);
        return;
    }

    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_NAME]);
}

static void
on_object_manager_created (GObject      *source_object,
                           GAsyncResult *res,
                           gpointer      user_data)
{
    CloudProvidersProvider *self;
    g_autoptr(GError) error = NULL;
    GDBusObjectManager *manager;

    manager = cloud_providers_dbus_object_manager_client_new_finish (res, &error);
    if (error != NULL)
    {
        g_printerr ("Error getting object manager client: %s", error->message);
        return;
    }

    /* The CloudProvidersProvider could be destroyed before arriving here */
    self = CLOUD_PROVIDERS_PROVIDER (user_data);
    self->manager = g_steal_pointer (&manager);
    g_signal_connect (self->manager, "notify::name-owner",
                      G_CALLBACK (on_cloud_providers_object_manager_name_owner_changed),
                      self);
    g_signal_connect (self->manager, "object-added",
                      G_CALLBACK (on_cloud_providers_object_manager_object_added),
                      self);
    g_signal_connect (self->manager, "object-removed",
                      G_CALLBACK (on_cloud_providers_object_manager_object_removed),
                      self);

    update_cloud_providers_accounts (self);
}

static void
on_bus_acquired (GObject      *source_object,
                 GAsyncResult *res,
                 gpointer      user_data)
{
    CloudProvidersProvider *self;
    g_autoptr(GError) error = NULL;
    GDBusConnection *connection;

    connection = g_bus_get_finish (res, &error);
    if (error != NULL)
    {
        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
            g_debug ("Error acquiring bus for cloud provider: %s", error->message);
        return;
    }

    /* The CloudProvidersProvider could be destroyed before arriving here */
    self = CLOUD_PROVIDERS_PROVIDER (user_data);
    self->bus = g_steal_pointer (&connection);
    cloud_providers_dbus_object_manager_client_new (self->bus,
                                                    G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
                                                    self->manager_bus_name,
                                                    self->manager_object_path,
                                                    self->cancellable,
                                                    on_object_manager_created,
                                                    self);
}


static void
cloud_providers_provider_init (CloudProvidersProvider *self)
{
    self->cancellable = g_cancellable_new ();
    g_bus_get (G_BUS_TYPE_SESSION,
               self->cancellable,
               on_bus_acquired,
               self);
}


const gchar*
cloud_providers_provider_get_name (CloudProvidersProvider *self)
{
    g_return_val_if_fail (CLOUD_PROVIDERS_IS_PROVIDER (self), NULL);

    return self->name;
}

/**
 * cloud_providers_provider_get_accounts
 * @self: A CloudProvidersProvider
 * Returns: (element-type CloudProviders.Account) (transfer none): A GList* of #CloudProvidersProvider objects.
 */
GList*
cloud_providers_provider_get_accounts (CloudProvidersProvider *self)
{
    g_return_val_if_fail (CLOUD_PROVIDERS_IS_PROVIDER (self), NULL);

    return self->accounts;
}


0707010000001E000081A400000000000000000000000165FAB139000005FF000000000000000000000000000000000000003500000000libcloudproviders-0.3.6/src/cloudprovidersprovider.h/* cloudprovidersprovider.h
 *
 * Copyright (C) 2017 Carlos Soriano <csoriano@gnome.org>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef CLOUD_PROVIDERS_PROVIDER_H
#define CLOUD_PROVIDERS_PROVIDER_H

#include <gio/gio.h>
#include "cloudprovidersaccount.h"

G_BEGIN_DECLS

#define CLOUD_PROVIDERS_PROVIDER_DBUS_IFACE "org.freedesktop.CloudProviders.Provider"

#define CLOUD_PROVIDERS_TYPE_PROVIDER (cloud_providers_provider_get_type())

G_DECLARE_FINAL_TYPE (CloudProvidersProvider, cloud_providers_provider, CLOUD_PROVIDERS, PROVIDER, GObject)

CloudProvidersProvider *cloud_providers_provider_new (const gchar *bus_name,
                                                      const gchar *object_path);
const gchar* cloud_providers_provider_get_name (CloudProvidersProvider *self);
GList* cloud_providers_provider_get_accounts (CloudProvidersProvider *self);

G_END_DECLS

#endif /* CLOUD_PROVIDERS_PROVIDER_H */

0707010000001F000081A400000000000000000000000165FAB13900003227000000000000000000000000000000000000003D00000000libcloudproviders-0.3.6/src/cloudprovidersproviderexporter.c/* cloudprovidersexporter.c
 *
 * Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "cloudprovidersproviderexporter.h"
#include "cloudprovidersaccountexporterpriv.h"
#include "cloudprovidersproviderexporterpriv.h"
#include "cloudprovidersaccountexporter.h"
#include "cloudproviders-generated.h"
#include <gio/gio.h>

struct _CloudProvidersProviderExporter
{
  GObject parent;

  CloudProvidersDbusProvider *skeleton;
  GDBusConnection *bus;
  GDBusObjectManagerServer *manager;

  gchar *bus_name;
  gchar *bus_path;
  gchar *provider_bus_path;

  gchar *name;
  GList *accounts;
};

G_DEFINE_TYPE (CloudProvidersProviderExporter, cloud_providers_provider_exporter, G_TYPE_OBJECT)

enum
{
    PROP_0,
    PROP_NAME,
    PROP_BUS_NAME,
    PROP_BUS_PATH,
    PROP_BUS,
    N_PROPS
};

static GParamSpec *properties [N_PROPS];

/**
 * SECTION:cloudprovidersproviderexporter
 * @title: CloudProvidersProviderExporter
 * @short_description: Base object for representing a single provider
 * @include: src/cloudprovidersexporter.h
 *
 * #CloudProvidersProviderExporter is the base object representing a single cloud provider.
 * Multiple #CloudProvidersAccountExporter objects can be added with cloud_providers_provider_exporter_add_account()
 * After adding the initial set of accounts cloud_providers_provider_exporter_export_objects() must be called.
 */

static void
export_provider (CloudProvidersProviderExporter *self)
{
    g_autoptr(CloudProvidersDbusObjectSkeleton) provider_object_skeleton = NULL;

    provider_object_skeleton = cloud_providers_dbus_object_skeleton_new (self->provider_bus_path);
    cloud_providers_dbus_object_skeleton_set_provider (provider_object_skeleton, self->skeleton);
    g_dbus_object_manager_server_export (self->manager,
                                         G_DBUS_OBJECT_SKELETON (provider_object_skeleton));

    g_debug ("provider object path: %s %s\n", self->provider_bus_path,
             g_dbus_object_manager_get_object_path (G_DBUS_OBJECT_MANAGER (self->manager)));
}

static void
export_account (CloudProvidersProviderExporter *self,
                CloudProvidersAccountExporter  *account)
{
    CloudProvidersDbusAccount *account_skeleton;
    const gchar *account_object_path;
    g_autoptr(CloudProvidersDbusObjectSkeleton) account_object_skeleton = NULL;

    account_object_path = cloud_providers_account_exporter_get_object_path (account);
    account_skeleton = cloud_providers_account_exporter_get_skeleton (account);
    account_object_skeleton = cloud_providers_dbus_object_skeleton_new (account_object_path);
    cloud_providers_dbus_object_skeleton_set_account (account_object_skeleton, account_skeleton);
    g_dbus_object_manager_server_export (self->manager, G_DBUS_OBJECT_SKELETON (account_object_skeleton));
    g_debug ("account object path: %s %s\n", account_object_path,
             g_dbus_object_manager_get_object_path (G_DBUS_OBJECT_MANAGER (self->manager)));
}

static void
unexport_account(CloudProvidersProviderExporter *self,
                 CloudProvidersAccountExporter  *account)
{
    const gchar *object_path;
    CloudProvidersDbusAccount *account_skeleton;

    account_skeleton = cloud_providers_account_exporter_get_skeleton (account);
    object_path = g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (account_skeleton));
    g_dbus_object_manager_server_unexport (self->manager, object_path);
}

/**
 * cloud_providers_provider_exporter_add_account:
 * @self: The cloud provider exporter
 * @account: The account object
 *
 * Each cloud provider can have a variety of account associated with it. Use this
 * function to add the accounts the user set up. This function is currently only internal,
 * as we do automation for the dbus handling for adding and exporting an account.
 * This is handled in cloud_providers_account_exporter_new().
 */
void
cloud_providers_provider_exporter_add_account (CloudProvidersProviderExporter *self,
                                               CloudProvidersAccountExporter  *account)
{
  export_account (self, account);
  self->accounts = g_list_append (self->accounts, g_object_ref (account));
}

/**
 * cloud_providers_provider_exporter_remove_account:
 * @self: The cloud provider exporter
 * @account: The account object
 *
 * Each cloud provider can have a variety of account associated with it. Use this
 * function to remove the accounts that were added when created by cloud_providers_account_exporter_new().
 */
void
cloud_providers_provider_exporter_remove_account (CloudProvidersProviderExporter *self,
                                                  CloudProvidersAccountExporter  *account)
{
    GList *removed_account;

    unexport_account (self, account);
    removed_account = g_list_find (self->accounts, account);
    g_return_if_fail (removed_account != NULL);
    self->accounts = g_list_remove (self->accounts, removed_account);
    g_object_unref (account);
}

static void
cloud_providers_provider_exporter_get_property (GObject    *object,
                                                guint       prop_id,
                                                GValue     *value,
                                                GParamSpec *pspec)
{
    CloudProvidersProviderExporter *self = CLOUD_PROVIDERS_PROVIDER_EXPORTER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_value_set_string (value, self->name);
        }
        break;

        case PROP_BUS_NAME:
        {
            g_value_set_string (value, self->bus_name);
        }
        break;

        case PROP_BUS_PATH:
        {
            g_value_set_string (value, self->bus_path);
        }
        break;

        case PROP_BUS:
        {
            g_value_set_object (value, self->bus);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }

    }
}

static void
cloud_providers_provider_exporter_set_property (GObject      *object,
                                                guint         prop_id,
                                                const GValue *value,
                                                GParamSpec   *pspec)
{
    CloudProvidersProviderExporter *self = CLOUD_PROVIDERS_PROVIDER_EXPORTER (object);

    switch (prop_id)
    {
        case PROP_NAME:
        {
            g_free (self->name);
            self->name = g_value_dup_string (value);
            g_debug ("setting name %s\n", self->name);
            cloud_providers_dbus_provider_set_name (self->skeleton, self->name);
        }
        break;

        case PROP_BUS_NAME:
        {
            g_return_if_fail (self->bus_name == NULL);
            self->bus_name = g_value_dup_string (value);
        }
        break;

        case PROP_BUS_PATH:
        {
            g_return_if_fail (self->bus_path == NULL);
            self->bus_path = g_value_dup_string (value);
        }
        break;

        case PROP_BUS:
        {
            g_return_if_fail (self->bus == NULL);
            self->bus = g_value_dup_object (value);
        }
        break;

        default:
        {
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        }
    }
}

static void
cloud_providers_provider_exporter_dispose (GObject *object)
{
    CloudProvidersProviderExporter *self = (CloudProvidersProviderExporter *)object;

    g_clear_object (&self->skeleton);
    g_clear_object (&self->manager);
    g_clear_object (&self->bus);

    g_list_free_full (self->accounts, g_object_unref);
    self->accounts = NULL;

    G_OBJECT_CLASS (cloud_providers_provider_exporter_parent_class)->dispose (object);
}

static void
cloud_providers_provider_exporter_finalize (GObject *object)
{
    CloudProvidersProviderExporter *self = (CloudProvidersProviderExporter *)object;

    g_clear_pointer (&self->bus_name, g_free);
    g_clear_pointer (&self->bus_path, g_free);
    g_clear_pointer (&self->provider_bus_path, g_free);
    g_clear_pointer (&self->name, g_free);

    G_OBJECT_CLASS (cloud_providers_provider_exporter_parent_class)->finalize (object);
}

static void
cloud_providers_provider_exporter_constructed (GObject *object)
{
    CloudProvidersProviderExporter *self = CLOUD_PROVIDERS_PROVIDER_EXPORTER (object);

    self->manager = g_dbus_object_manager_server_new (self->bus_path);
    self->provider_bus_path = g_strconcat (self->bus_path, "/Provider", NULL);
    g_debug ("constructed, manager %s", self->bus_path);
    self->skeleton = cloud_providers_dbus_provider_skeleton_new ();
    g_dbus_object_manager_server_set_connection (self->manager, self->bus);
    export_provider (self);
}

static void
cloud_providers_provider_exporter_init (CloudProvidersProviderExporter *self)
{
}

static void
cloud_providers_provider_exporter_class_init (CloudProvidersProviderExporterClass *klass)
{
    GObjectClass *object_class = G_OBJECT_CLASS (klass);
    object_class->set_property = cloud_providers_provider_exporter_set_property;
    object_class->get_property = cloud_providers_provider_exporter_get_property;
    object_class->constructed = cloud_providers_provider_exporter_constructed;
    object_class->dispose = cloud_providers_provider_exporter_dispose;
    object_class->finalize = cloud_providers_provider_exporter_finalize;

    properties [PROP_NAME] =
        g_param_spec_string ("name",
                             "Name",
                             "The name of the cloud provider",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS));
    properties [PROP_BUS_NAME] =
        g_param_spec_string ("bus-name",
                             "BusName",
                             "BusName",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS |
                              G_PARAM_CONSTRUCT_ONLY));
    properties [PROP_BUS_PATH] =
        g_param_spec_string ("bus-path",
                             "BusPath",
                             "BusPath",
                             NULL,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS |
                              G_PARAM_CONSTRUCT_ONLY));

    properties [PROP_BUS] =
        g_param_spec_object ("bus",
                             "Bus",
                             "Bus",
                             G_TYPE_DBUS_CONNECTION,
                             (G_PARAM_READWRITE |
                              G_PARAM_STATIC_STRINGS |
                              G_PARAM_CONSTRUCT_ONLY));
    g_object_class_install_properties (object_class,
                                       N_PROPS,
                                       properties);
}

void
cloud_providers_provider_exporter_set_name (CloudProvidersProviderExporter *self,
                                            const gchar                    *name)
{
    g_object_set (self, "name", name, NULL);
}

const gchar*
cloud_providers_provider_exporter_get_name (CloudProvidersProviderExporter *self)
{
    return self->name;
}

/**
 * cloud_providers_provider_exporter_new
 * @bus: A #GDBusConnection to export the objects to
 * @bus_name: A DBus name to bind to
 * @bus_path: A DBus object path
 */
CloudProvidersProviderExporter *
cloud_providers_provider_exporter_new (GDBusConnection *bus,
                                       const gchar     *bus_name,
                                       const gchar     *bus_path)
{
  CloudProvidersProviderExporter *self;

  self = g_object_new (CLOUD_PROVIDERS_TYPE_PROVIDER_EXPORTER,
                       "bus", bus,
                       "bus-name", bus_name,
                       "bus-path", bus_path,
                       NULL);

  return self;
}

GDBusConnection*
cloud_providers_provider_exporter_get_bus (CloudProvidersProviderExporter *self)
{
    return self->bus;
}

const gchar*
cloud_providers_provider_exporter_get_object_path (CloudProvidersProviderExporter *self)
{
    return self->bus_path;
}
07070100000020000081A400000000000000000000000165FAB139000007AE000000000000000000000000000000000000003D00000000libcloudproviders-0.3.6/src/cloudprovidersproviderexporter.h/* cloudprovidersexporter.h
 *
 * Copyright (C) 2017 Julius Haertl <jus@bitgrid.net>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLOUD_PROVIDERS_PROVIDER_EXPORTER_H
#define CLOUD_PROVIDERS_PROVIDER_EXPORTER_H

#include <gio/gio.h>
#include "cloudprovidersaccountexporter.h"

G_BEGIN_DECLS

#define CLOUD_PROVIDERS_TYPE_PROVIDER_EXPORTER (cloud_providers_provider_exporter_get_type())
G_DECLARE_FINAL_TYPE (CloudProvidersProviderExporter, cloud_providers_provider_exporter, CLOUD_PROVIDERS, PROVIDER_EXPORTER, GObject)

struct _CloudProvidersProviderExporterClass
{
  GObjectClass parent_class;
};

void
cloud_providers_provider_exporter_remove_account (CloudProvidersProviderExporter *self,
                                                  CloudProvidersAccountExporter  *account);

void
cloud_providers_provider_exporter_set_name (CloudProvidersProviderExporter *self,
                                            const gchar                    *name);
const gchar*
cloud_providers_provider_exporter_get_name (CloudProvidersProviderExporter *self);

CloudProvidersProviderExporter*
cloud_providers_provider_exporter_new (GDBusConnection *bus,
                                       const gchar     *bus_name,
                                       const gchar     *bus_path);

G_END_DECLS

#endif /* CLOUD_PROVIDERS_PROVIDER_EXPORTER_H */
07070100000021000081A400000000000000000000000165FAB13900000567000000000000000000000000000000000000004100000000libcloudproviders-0.3.6/src/cloudprovidersproviderexporterpriv.h/* cloudprovidersproviderexporterpriv.h
 *
 * Copyright (C) 2017 Carlos Soriano <csoriano@gnome.org>
 *
 * This file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CLOUD_PROVIDERS_PROVIDER_EXPORTER_PRIV_H
#define CLOUD_PROVIDERS_PROVIDER_EXPORTER_PRIV_H

#include <gio/gio.h>
#include "cloudprovidersproviderexporter.h"
#include "cloudproviders-generated.h"
G_BEGIN_DECLS

void
cloud_providers_provider_exporter_add_account (CloudProvidersProviderExporter *self,
                                               CloudProvidersAccountExporter  *account);
const gchar*
cloud_providers_provider_exporter_get_object_path (CloudProvidersProviderExporter *self);

GDBusConnection*
cloud_providers_provider_exporter_get_bus (CloudProvidersProviderExporter *self);

G_END_DECLS

#endif
07070100000022000081A400000000000000000000000165FAB13900000A62000000000000000000000000000000000000002800000000libcloudproviders-0.3.6/src/meson.buildlibcloudproviders_deps = [glib, gio, gio_platform]

libcloudproviders_headers = [
  'cloudproviders.h',
  'cloudproviderscollector.h',
  'cloudprovidersaccount.h',
  'cloudprovidersaccountexporter.h',
  'cloudprovidersprovider.h',
  'cloudprovidersproviderexporter.h',
]

libcloudproviders_sources = [
  'cloudproviderscollector.c',
  'cloudprovidersaccount.c',
  'cloudprovidersaccountexporter.c',
  'cloudprovidersprovider.c',
  'cloudprovidersproviderexporter.c',
]

headers_with_enums = gnome.mkenums_simple('enums',
                                          sources : libcloudproviders_headers,
                                          install_dir: incdir,
                                          install_header: true)

generated_sources = []
generated_sources += gnome.gdbus_codegen(
  'cloudproviders-generated', '../data/cloud-providers-dbus.xml',
  interface_prefix: 'org.freedesktop.CloudProviders',
  namespace: 'CloudProvidersDbus',
  object_manager: true
)

libcloudproviders_sources += generated_sources

libcloudproviders = shared_library ('cloudproviders',
  libcloudproviders_sources, headers_with_enums,
  dependencies: libcloudproviders_deps,
  soversion: libcloudproviders_soversion,
  version: libcloudproviders_library_version,
  install: true
)

install_headers (libcloudproviders_headers, subdir: 'cloudproviders')

pkg = import('pkgconfig')
pkg.generate(
  libraries : libcloudproviders,
  subdirs : 'cloudproviders',
  version : meson.project_version(),
  name : 'libcloudproviders',
  filebase: 'cloudproviders',
  description : 'Cloud providers DBus API library.'
)

libcloudproviders_dep = declare_dependency (
  link_with: libcloudproviders,
  dependencies: libcloudproviders_deps,
  include_directories: include_directories('.')
)
meson.override_dependency('libcloudproviders', libcloudproviders_dep)

if get_option('introspection')
  libcloudproviders_gir = gnome.generate_gir(
    libcloudproviders,
    sources: libcloudproviders_headers + libcloudproviders_sources,
    nsversion: libcloudproviders_api_version,
    dependencies: libcloudproviders_deps,
    namespace: 'CloudProviders',
    symbol_prefix: 'cloud_providers',
    link_with: libcloudproviders,
    includes: [ 'GLib-2.0', 'Gio-2.0' ],
    install: true,
    install_dir_gir: girdir,
    install_dir_typelib: typelibdir,
    extra_args: [ '--c-include=cloudproviders/cloudproviders.h', '--quiet' ]
  )
endif

vapigen_dep = find_program('vapigen', required : false)

if get_option('vapigen')
  libcloudproviders_vapi = gnome.generate_vapi(
    'cloudproviders',
    sources: libcloudproviders_gir[0],
    packages: ['gio-2.0'],
    install: true,
  )
endif
07070100000023000041ED00000000000000000000000265FAB13900000000000000000000000000000000000000000000001D00000000libcloudproviders-0.3.6/test07070100000024000081A400000000000000000000000165FAB13900002BC0000000000000000000000000000000000000002600000000libcloudproviders-0.3.6/test/icon.svg<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg xmlns:cc='http://creativecommons.org/ns#' xmlns:dc='http://purl.org/dc/elements/1.1/' sodipodi:docname='application-x-appliance-symbolic.svg' height='16.03125' id='svg7384' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:svg='http://www.w3.org/2000/svg' inkscape:version='0.48.4 r9939' version='1.1' width='16.03125' xmlns='http://www.w3.org/2000/svg'>
  <metadata id='metadata90'>
    <rdf:RDF>
      <cc:Work rdf:about=''>
        <dc:format>image/svg+xml</dc:format>
        <dc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/>
        <dc:title>Gnome Symbolic Icon Theme</dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <sodipodi:namedview inkscape:bbox-nodes='false' inkscape:bbox-paths='true' bordercolor='#666666' borderopacity='1' inkscape:current-layer='layer14' inkscape:cx='-2.88943' inkscape:cy='-0.340373' gridtolerance='10' inkscape:guide-bbox='true' guidetolerance='10' id='namedview88' inkscape:object-nodes='false' inkscape:object-paths='false' objecttolerance='10' pagecolor='#3a3b39' inkscape:pageopacity='1' inkscape:pageshadow='2' showborder='false' showgrid='false' showguides='true' inkscape:snap-bbox='true' inkscape:snap-bbox-midpoints='false' inkscape:snap-global='true' inkscape:snap-grids='true' inkscape:snap-nodes='false' inkscape:snap-others='false' inkscape:snap-to-guides='true' inkscape:window-height='1381' inkscape:window-maximized='1' inkscape:window-width='2560' inkscape:window-x='0' inkscape:window-y='27' inkscape:zoom='1'>
    <inkscape:grid empspacing='2' enabled='true' id='grid4866' originx='-340px' originy='84.03125px' snapvisiblegridlinesonly='true' spacingx='1px' spacingy='1px' type='xygrid' visible='true'/>
  </sodipodi:namedview>
  <title id='title9167'>Gnome Symbolic Icon Theme</title>
  <defs id='defs7386'/>
  <g inkscape:groupmode='layer' id='layer9' inkscape:label='status' style='display:inline' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='layer10' inkscape:label='devices' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='layer11' inkscape:label='apps' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='layer13' inkscape:label='places' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='layer14' inkscape:label='mimetypes' transform='translate(-581.0002,-301)'>
    
    <path sodipodi:cx='-176.01562' sodipodi:cy='-39.984375' d='m -174,-39.984375 a 2.015625,2.015625 0 1 1 -4.03125,0 2.015625,2.015625 0 1 1 4.03125,0 z' id='path3908-61' sodipodi:rx='2.015625' sodipodi:ry='2.015625' style='color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='translate(759.03145,343.03125)' sodipodi:type='arc'/>
    <path sodipodi:cx='-176.01562' sodipodi:cy='-39.984375' d='m -174,-39.984375 a 2.015625,2.015625 0 1 1 -4.03125,0 2.015625,2.015625 0 1 1 4.03125,0 z' id='path3910-1' sodipodi:rx='2.015625' sodipodi:ry='2.015625' style='color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='translate(759.03145,354.96875)' sodipodi:type='arc'/>
    <path sodipodi:cx='-176.01562' sodipodi:cy='-39.984375' d='m -174,-39.984375 a 2.015625,2.015625 0 1 1 -4.03125,0 2.015625,2.015625 0 1 1 4.03125,0 z' id='path3912' sodipodi:rx='2.015625' sodipodi:ry='2.015625' style='color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='translate(771.03145,354.96875)' sodipodi:type='arc'/>
    <path sodipodi:cx='-176.01562' sodipodi:cy='-39.984375' d='m -174,-39.984375 a 2.015625,2.015625 0 1 1 -4.03125,0 2.015625,2.015625 0 1 1 4.03125,0 z' id='path3914' sodipodi:rx='2.015625' sodipodi:ry='2.015625' style='color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='translate(771.03145,343)' sodipodi:type='arc'/>
    <path inkscape:connector-curvature='0' d='m 582.0625,302.0625 0,1 0,11.96875 0,1 1,0 11.96875,0 1,0 0,-1 0,-11.96875 0,-1 -1,0 -11.96875,0 -1,0 z m 2,2 9.96875,0 0,9.96875 -9.96875,0 0,-9.96875 z' id='rect3916' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
    <path inkscape:connector-curvature='0' d='m 585.96875,306.03125 0,0.5 0,5 0,0.5 0.5,0 5.0625,0 0.5,0 0,-0.5 0,-5 0,-0.5 -0.5,0 -5.0625,0 -0.5,0 z m 1,1 4.0625,0 0,4 -4.0625,0 0,-4 z' id='rect3918' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.9999997;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
    <path sodipodi:cx='-167.76562' sodipodi:cy='-31.765625' d='m -166.5,-31.765625 a 1.265625,1.265625 0 1 1 -2.53125,0 1.265625,1.265625 0 1 1 2.53125,0 z' id='path3937' sodipodi:rx='1.265625' sodipodi:ry='1.265625' style='color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(1.1975309,0,0,1.1975309,792.42034,349.55594)' sodipodi:type='arc'/>
    <path sodipodi:cx='-167.76562' sodipodi:cy='-31.765625' d='m -166.5,-31.765625 a 1.265625,1.265625 0 1 1 -2.53125,0 1.265625,1.265625 0 1 1 2.53125,0 z' id='path3939' sodipodi:rx='1.265625' sodipodi:ry='1.265625' style='color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(1.1975309,0,0,1.1975309,787.42034,349.55594)' sodipodi:type='arc'/>
    <path sodipodi:cx='-167.76562' sodipodi:cy='-31.765625' d='m -166.5,-31.765625 a 1.265625,1.265625 0 1 1 -2.53125,0 1.265625,1.265625 0 1 1 2.53125,0 z' id='path3941' sodipodi:rx='1.265625' sodipodi:ry='1.265625' style='color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(1.1975309,0,0,1.1975309,787.42034,344.58719)' sodipodi:type='arc'/>
    <path sodipodi:cx='-167.76562' sodipodi:cy='-31.765625' d='m -166.5,-31.765625 a 1.265625,1.265625 0 1 1 -2.53125,0 1.265625,1.265625 0 1 1 2.53125,0 z' id='path3943' sodipodi:rx='1.265625' sodipodi:ry='1.265625' style='color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(1.1975309,0,0,1.1975309,792.48284,344.58719)' sodipodi:type='arc'/>
    <path inkscape:connector-curvature='0' d='m 591.875,311.21875 -0.6875,0.6875 3.40625,3.4375 0.71875,-0.71875 -3.4375,-3.40625 z' id='path3945' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
    <path inkscape:connector-curvature='0' d='m 586.59375,311.21875 -3.40625,3.40625 0.6875,0.71875 3.4375,-3.4375 -0.71875,-0.6875 z' id='path3949' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
    <path inkscape:connector-curvature='0' d='m 594.59375,303.21875 -3.40625,3.40625 0.6875,0.71875 3.4375,-3.4375 -0.71875,-0.6875 z' id='path3953' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
    <path inkscape:connector-curvature='0' d='m 583.875,303.21875 -0.6875,0.6875 3.40625,3.4375 0.71875,-0.71875 -3.4375,-3.40625 z' id='path3955' style='font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.99999976;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new;font-family:Sans;-inkscape-font-specification:Sans'/>
  </g>
  <g inkscape:groupmode='layer' id='layer15' inkscape:label='emblems' style='display:inline' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='g71291' inkscape:label='emotes' style='display:inline' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='g4953' inkscape:label='categories' style='display:inline' transform='translate(-581.0002,-301)'/>
  <g inkscape:groupmode='layer' id='layer12' inkscape:label='actions' style='display:inline' transform='translate(-581.0002,-301)'/>
</svg>
07070100000025000081A400000000000000000000000165FAB13900000425000000000000000000000000000000000000002900000000libcloudproviders-0.3.6/test/meson.buildinstalled = get_option('installed-tests')
executable('testcloudprovidersserver', 'testcloudprovidersserver.c',
  dependencies: libcloudproviders_dep,
  install: installed,
)
executable('testcloudprovidersclient', 'testcloudprovidersclient.c',
  dependencies: libcloudproviders_dep,
  install: installed,
)

configure_file(input : 'icon.svg',
               output : 'icon.svg',
               copy : true)

if installed
  service_conf = configuration_data ()
  service_conf.set ('bindir', join_paths (prefix, bindir))
  configure_file(
    input: 'org.freedesktop.CloudProviders.ServerExample.service.in',
    output: 'org.freedesktop.CloudProviders.ServerExample.service',
    configuration: service_conf,
    install_dir: servicedir,
  )
  applications = join_paths (datadir, 'applications')
  cloudprovidersdata = join_paths (datadir, 'cloud-providers')
  install_data('org.freedesktop.CloudProviders.ServerExample.desktop', install_dir: applications)
  install_data('org.freedesktop.CloudProviders.ServerExample.ini', install_dir: cloudprovidersdata)
endif
07070100000026000081A400000000000000000000000165FAB1390000010F000000000000000000000000000000000000005200000000libcloudproviders-0.3.6/test/org.freedesktop.CloudProviders.ServerExample.desktop[Desktop Entry]
Type=Application
Name=libcloudproviders example server
NoDisplay=true
Implements=org.freedesktop.CloudProviders

[org.freedesktop.CloudProviders]
BusName=org.freedesktop.CloudProviders.ServerExample
ObjectPath=/org/freedesktop/CloudProviders/ServerExample07070100000027000081A400000000000000000000000165FAB1390000008A000000000000000000000000000000000000004E00000000libcloudproviders-0.3.6/test/org.freedesktop.CloudProviders.ServerExample.ini[Cloud Providers]
BusName=org.freedesktop.CloudProviders.ServerExample
ObjectPath=/org/freedesktop/CloudProviders/ServerExample
Version=1
07070100000028000081A400000000000000000000000165FAB13900000069000000000000000000000000000000000000005500000000libcloudproviders-0.3.6/test/org.freedesktop.CloudProviders.ServerExample.service.in[D-BUS Service]
Name=org.freedesktop.CloudProviders.ServerExample
Exec=@bindir@/testcloudprovidersserver
07070100000029000081A400000000000000000000000165FAB139000019F4000000000000000000000000000000000000003800000000libcloudproviders-0.3.6/test/testcloudprovidersclient.c#include <glib.h>
#include <cloudprovidersaccount.h>
#include <cloudproviderscollector.h>
#include <cloudprovidersprovider.h>

static void
print_gmenu_model (GMenuModel  *model)
{
  gint i, n_items;
  GMenuModel *submodel = NULL;
  gchar *label;

  n_items = g_menu_model_get_n_items (model);

  for (i = 0; i < n_items; i++)
    {
      label = NULL;
      if (g_menu_model_get_item_attribute (model, i, G_MENU_ATTRIBUTE_LABEL, "s", &label))
        {
          g_print ("Menu item - %s\n", label);
          if (label != NULL)
            g_free (label);
        }

      submodel = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
      if (!submodel)
       submodel = g_menu_model_get_item_link (model, i, G_MENU_LINK_SUBMENU);

      if (!submodel)
          continue;
      g_print ("---------\n");
      print_gmenu_model (submodel);
      g_print ("---------\n");
      g_clear_object (&submodel);
  }
}

static gchar*
get_status_string (CloudProvidersAccountStatus status)
{
  gchar *status_string;

  switch (status)
    {
    case CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID:
      status_string = "invalid";
      break;

    case CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE:
      status_string = "idle";
      break;

    case CLOUD_PROVIDERS_ACCOUNT_STATUS_SYNCING:
      status_string = "syncing";
      break;

    case CLOUD_PROVIDERS_ACCOUNT_STATUS_ERROR:
      status_string = "error";
      break;

    default:
      g_assert_not_reached ();
    }

  return g_strdup (status_string);
}

static void
on_account_status_changed (CloudProvidersAccount *account)
{
    g_autofree gchar* status_string = NULL;
    GIcon *icon;
    g_autofree gchar *icon_representation = NULL;
    GMenuModel *menu;

    icon = cloud_providers_account_get_icon (account);
    icon_representation = g_icon_to_string (icon);
    status_string = get_status_string (cloud_providers_account_get_status (account));
    g_print ("Account: Name - %s, Status - %s (%s), Path - %s, Icon - %s\n",
             cloud_providers_account_get_name (account),
             status_string,
             cloud_providers_account_get_status_details (account),
             cloud_providers_account_get_path (account),
             icon_representation);
    menu = cloud_providers_account_get_menu_model (account);
    g_print ("\nMenu\n");
    print_gmenu_model (menu);
}

static void
on_provider_accounts_changed (CloudProvidersProvider *provider)
{
    GList *l;
    gint status;
    GIcon *icon;
    GList *accounts;
    GMenuModel *menu;

    accounts = cloud_providers_provider_get_accounts (provider);
    for (l = accounts; l != NULL; l = l->next)
    {
        CloudProvidersAccount *account;
        g_autofree gchar *status_string = NULL;
        g_autofree gchar *icon_representation = NULL;

        account = CLOUD_PROVIDERS_ACCOUNT (l->data);
        g_signal_connect (account,
                          "notify::status",
                          G_CALLBACK (on_account_status_changed),
                          NULL);
        status = cloud_providers_account_get_status (account);
        status_string = get_status_string (status);
        icon = cloud_providers_account_get_icon (account);
        icon_representation = icon != NULL ? g_icon_to_string (icon) : g_strdup ("no icon");

        g_print ("Account: Name - %s, Status - %s (%s), Path - %s, Icon - %s\n",
                 cloud_providers_account_get_name (account),
                 status_string,
                 cloud_providers_account_get_status_details (account),
                 cloud_providers_account_get_path (account),
                 icon_representation);

        menu = cloud_providers_account_get_menu_model (account);
        g_print ("\nMenu\n");
        print_gmenu_model (menu);
    }
}

static void
on_provider_name_changed (CloudProvidersProvider *provider)
{
    g_print ("Provider changed: %s\n", cloud_providers_provider_get_name (provider));
}

static void
on_collector_changed (CloudProvidersCollector *collector)
{
    GList *providers;
    GList *accounts;
    GList *l;
    GList *l2;
    gint status;
    GIcon *icon;
    GMenuModel *menu;

    providers = cloud_providers_collector_get_providers (collector);
    if (providers == NULL)
    {
        return;
    }

  for (l = providers; l != NULL; l = l->next)
  {
      CloudProvidersProvider *provider;

      provider = CLOUD_PROVIDERS_PROVIDER (l->data);
      g_print ("Provider data for %s\n", cloud_providers_provider_get_name (provider));
      g_print ("--------------------------\n");
      accounts = cloud_providers_provider_get_accounts (provider);
      for (l2 = accounts; l2 != NULL; l2 = l2->next)
      {
          CloudProvidersAccount *account;
          g_autofree gchar *status_string = NULL;
          g_autofree gchar *icon_representation = NULL;

          account = CLOUD_PROVIDERS_ACCOUNT (l2->data);
          g_signal_connect_swapped (account,
                                    "notify::status",
                                    G_CALLBACK (on_account_status_changed),
                                    NULL);
          status = cloud_providers_account_get_status (account);
          status_string = get_status_string (status);
          icon = cloud_providers_account_get_icon (account);
          icon_representation = g_icon_to_string (icon);

          g_print ("Account: Name - %s, Status - %s (%s), Path - %s, Icon - %s\n",
                   cloud_providers_account_get_name (account),
                   status_string,
                   cloud_providers_account_get_status_details (account),
                   cloud_providers_account_get_path (account),
                   icon_representation);

          menu = cloud_providers_account_get_menu_model (account);
          g_print ("\nMenu\n");
          print_gmenu_model (menu);
      }

      g_signal_connect_swapped (provider, "accounts-changed",
                                G_CALLBACK (on_provider_accounts_changed), provider);
      g_signal_connect_swapped (provider, "notify::name",
                                G_CALLBACK (on_provider_name_changed), provider);
  }
  g_print ("\n");
}

gint
main (gint   argc,
      gchar *argv[])
{
  CloudProvidersCollector *collector;
  GMainLoop *loop = g_main_loop_new(NULL, FALSE);

  collector = cloud_providers_collector_dup_singleton ();
  g_signal_connect_swapped (collector, "providers-changed",
                            G_CALLBACK (on_collector_changed), collector);
  on_collector_changed (collector);

  g_print("Waiting for cloud providers\n\n");
  g_main_loop_run(loop);
  g_main_loop_unref(loop);
  g_object_unref (collector);

  return 0;
}
0707010000002A000081A400000000000000000000000165FAB13900002C76000000000000000000000000000000000000003800000000libcloudproviders-0.3.6/test/testcloudprovidersserver.c#include <glib.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <cloudprovidersproviderexporter.h>
#include <cloudprovidersaccountexporter.h>
/* for CLoudProviderStatus enum */
#include <cloudprovidersaccount.h>


#define TIMEOUT 800
#define COUNT_PLACEHOLDER_ACCOUNTS 3
#define TEST_CLOUD_PROVIDERS_BUS_NAME "org.freedesktop.CloudProviders.ServerExample"
#define TEST_CLOUD_PROVIDERS_OBJECT_PATH "/org/freedesktop/CloudProviders/ServerExample"

#define CLOUD_PROVIDERS_TYPE_TEST_SERVER (cloud_providers_test_server_get_type())
G_DECLARE_FINAL_TYPE (CloudProvidersTestServer, cloud_providers_test_server, CLOUD_PROVIDERS, TEST_SERVER, GObject);

struct _CloudProvidersTestServerClass
{
  GObjectClass parent_class;
};

struct _CloudProvidersTestServer
{
  GObject parent_instance;

  GHashTable *accounts;
  gchar *name;
  GIcon *icon;
  gchar *path;
  guint timeout_handler;
  CloudProvidersProviderExporter *exporter;
};

G_DEFINE_TYPE (CloudProvidersTestServer, cloud_providers_test_server, G_TYPE_OBJECT);

static CloudProvidersTestServer*
cloud_providers_test_server_new (void)
{
  CloudProvidersTestServer *self;

  self = g_object_new (CLOUD_PROVIDERS_TYPE_TEST_SERVER, NULL);

  return self;
}

static void
test_cloud_provider_finalize (GObject *object)
{
  CloudProvidersTestServer *self = CLOUD_PROVIDERS_TEST_SERVER (object);

  g_clear_handle_id (&self->timeout_handler, g_source_remove);
  g_clear_pointer (&self->accounts, g_hash_table_unref);
  g_clear_pointer (&self->name, g_free);
  g_clear_pointer (&self->path, g_free);
  g_clear_object (&self->icon);
  g_clear_object (&self->exporter);

  G_OBJECT_CLASS (cloud_providers_test_server_parent_class)->finalize (object);
}

static void
cloud_providers_test_server_init (CloudProvidersTestServer *self)
{
  g_autoptr(GFile) icon_file = NULL;
  g_autofree gchar *current_dir = NULL;
  g_autofree gchar *uri = NULL;

  current_dir = g_get_current_dir ();

  self->accounts = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
  self->name = g_strdup ("MyCloud");
  self->path = g_strdup (current_dir);
  uri = g_build_filename (current_dir, "icon.svg", NULL);
  icon_file = g_file_new_for_uri (uri);
  self->icon = g_file_icon_new (icon_file);
}

static void
cloud_providers_test_server_class_init (CloudProvidersTestServerClass *class)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);

  gobject_class->finalize = test_cloud_provider_finalize;
}

/* ---------------------------------------------------------------------------------------------------- */

static void
activate_action (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
{
  g_print ("Action %s activated\n", g_action_get_name (G_ACTION (action)));
}

static void
activate_toggle (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
{
  GVariant *old_state, *new_state;

  old_state = g_action_get_state (G_ACTION (action));
  new_state = g_variant_new_boolean (!g_variant_get_boolean (old_state));

  g_print ("Toggle action %s activated, state changes from %d to %d\n",
           g_action_get_name (G_ACTION (action)),
           g_variant_get_boolean (old_state),
           g_variant_get_boolean (new_state));

  g_simple_action_set_state (action, new_state);
  g_variant_unref (old_state);
}

static void
activate_radio (GSimpleAction *action,
                GVariant      *parameter,
                gpointer       user_data)
{
  GVariant *old_state, *new_state;

  old_state = g_action_get_state (G_ACTION (action));
  new_state = g_variant_new_string (g_variant_get_string (parameter, NULL));

  g_print ("Radio action %s activated, state changes from %s to %s\n",
           g_action_get_name (G_ACTION (action)),
           g_variant_get_string (old_state, NULL),
           g_variant_get_string (new_state, NULL));

  g_simple_action_set_state (action, new_state);
  g_variant_unref (old_state);
}

static GActionEntry actions[] = {
  { "website",  activate_action, NULL, NULL, NULL },
  { "photos",  activate_action, NULL, NULL, NULL },
  { "notes",   activate_action, NULL, NULL, NULL },
  { "allow-sync",  activate_toggle, NULL, "true", NULL },
  { "buy",  activate_radio,  "s",  NULL, NULL },
};

static GMenuModel *
get_model (void)
{
  GMenu *section;
  GMenu *mainMenu;
  GMenuItem *website;
  GMenuItem *photos;
  GMenuItem *notes;
  GMenuItem *allowSync;
  GMenuItem *item;
  GMenu *submenu;

  mainMenu = g_menu_new();

  section = g_menu_new();
  website = g_menu_item_new("MyCloud website", "cloudprovider.website");
  g_menu_append_item(section, website);
  g_object_unref (website);
  photos = g_menu_item_new("MyCloud photos", "cloudprovider.photos");
  g_menu_append_item(section, photos);
  g_object_unref (photos);
  notes = g_menu_item_new("MyCloud notes", "cloudprovider.notes");
  g_menu_append_item(section, notes);
  g_object_unref (notes);
  g_menu_append_section(mainMenu, NULL, G_MENU_MODEL(section));
  g_object_unref (section);

  section = g_menu_new();
  allowSync = g_menu_item_new("Allow Synchronization", "cloudprovider.allow-sync");
  g_menu_append_item(section, allowSync);
  g_object_unref (allowSync);

  submenu = g_menu_new();
  item = g_menu_item_new("5GB", "5");
  g_menu_append_item(submenu, item);
  g_object_unref (item);
  item = g_menu_item_new("10GB", "10");
  g_menu_append_item(submenu, item);
  g_object_unref (item);
  item = g_menu_item_new("50GB", "50");
  g_menu_append_item(submenu, item);
  g_object_unref (item);
  item = g_menu_item_new_submenu("Buy storage", G_MENU_MODEL(submenu));
  g_menu_append_item(section, item);
  g_object_unref (item);
  g_object_unref (submenu);
  g_menu_append_section(mainMenu, NULL, G_MENU_MODEL(section));
  g_object_unref (section);

  return G_MENU_MODEL(mainMenu);
}

static GActionGroup *
get_action_group (void)
{
  GSimpleActionGroup *group;

  group = g_simple_action_group_new ();

  g_action_map_add_action_entries (G_ACTION_MAP (group),
                                   actions,
                                   G_N_ELEMENTS (actions), NULL);

  return G_ACTION_GROUP (group);
}

static gboolean
change_random_cloud_provider_state (gpointer user_data)
{
  CloudProvidersTestServer *self = (CloudProvidersTestServer *)user_data;
  CloudProvidersAccountExporter *account;
  GRand *rand;
  gint new_status;
  gint account_id;

  rand = g_rand_new ();
  account_id = g_rand_int_range (rand, 0, COUNT_PLACEHOLDER_ACCOUNTS);
  new_status = g_rand_int_range (rand,
                                 CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE,
                                 CLOUD_PROVIDERS_ACCOUNT_STATUS_ERROR + 1);
  g_rand_free (rand);

  g_print ("Change status of %03d to %d\n", account_id, new_status);
  account = g_hash_table_lookup (self->accounts, GINT_TO_POINTER (account_id));
  cloud_providers_account_exporter_set_status (account, new_status);

  return TRUE;
}

static const gchar *
get_status_details (CloudProvidersAccountStatus status)
{
    gchar *description = "";
    switch (status) {
      case CLOUD_PROVIDERS_ACCOUNT_STATUS_IDLE:
        description = "Details: Sync idle";
        break;
      case CLOUD_PROVIDERS_ACCOUNT_STATUS_SYNCING:
        description = "Details: Syncing";
        break;
      case CLOUD_PROVIDERS_ACCOUNT_STATUS_ERROR:
        description = "Details: Error";
        break;
      case CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID:
        description = "Details: Sync status details not set";
        break;
    }
    return description;
}

static gboolean
add_accounts (CloudProvidersTestServer *self)
{
  guint n;

  // export multiple accounts as DBus objects to the bus
  for (n = 0; n < COUNT_PLACEHOLDER_ACCOUNTS; n++)
    {
      g_autoptr (CloudProvidersAccountExporter) account = NULL;
      g_autofree gchar *account_object_name = NULL;
      g_autofree gchar *account_name = NULL;
      GActionGroup *action_group = get_action_group ();
      g_autoptr(GMenuModel) menu_model = get_model ();

      account_object_name = g_strdup_printf ("MyAccount%d", n);
      account_name = g_strdup_printf ("MyAccount %d", n);
      g_debug ("Adding account %s", account_name);
      account = cloud_providers_account_exporter_new (self->exporter,
                                                      account_object_name);

      cloud_providers_account_exporter_set_name (account, account_name);
      cloud_providers_account_exporter_set_icon (account, self->icon);
      cloud_providers_account_exporter_set_path (account, self->path);
      cloud_providers_account_exporter_set_status (account,
                                                   CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID);
      cloud_providers_account_exporter_set_status_details (account,
                                                           get_status_details (CLOUD_PROVIDERS_ACCOUNT_STATUS_INVALID));
      cloud_providers_account_exporter_set_menu_model (account, menu_model);
      cloud_providers_account_exporter_set_action_group (account, action_group);
      g_hash_table_insert (self->accounts, GINT_TO_POINTER (n), g_steal_pointer (&account));
      g_object_unref (action_group);
    }

    return G_SOURCE_REMOVE;
}

static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
    CloudProvidersTestServer *self = CLOUD_PROVIDERS_TEST_SERVER (user_data);

    g_debug ("Bus acquired: %s\n", name);

    g_debug ("Registering cloud provider server 'MyCloud'\n");

    self->exporter = cloud_providers_provider_exporter_new(connection,
                                                           TEST_CLOUD_PROVIDERS_BUS_NAME,
                                                           TEST_CLOUD_PROVIDERS_OBJECT_PATH);
    cloud_providers_provider_exporter_set_name (self->exporter, "My cloud");
    add_accounts (self);

}

static void
on_name_acquired (GDBusConnection *connection,
                  const gchar     *name,
                  gpointer         user_data)
{
  CloudProvidersTestServer *self = (CloudProvidersTestServer *)user_data;
  self->timeout_handler = g_timeout_add (TIMEOUT,
                                         (GSourceFunc) change_random_cloud_provider_state,
                                         self);
  g_debug ("Server test name acquired");
  change_random_cloud_provider_state (self);
}

static void
on_name_lost (GDBusConnection *connection,
              const gchar     *name,
              gpointer         user_data)
{
    g_critical ("Name lost: %s\n", name);
}

int
main (int argc, char *argv[])
{
  GMainLoop *loop;
  CloudProvidersTestServer *test_cloud_provider;
  guint owner_id;

  test_cloud_provider = cloud_providers_test_server_new ();

  owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
                             TEST_CLOUD_PROVIDERS_BUS_NAME,
                             G_BUS_NAME_OWNER_FLAGS_NONE,
                             on_bus_acquired,
                             on_name_acquired,
                             on_name_lost,
                             test_cloud_provider,
                             NULL);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);
  g_main_loop_unref (loop);
    g_debug("going oooooout/n");
  g_bus_unown_name (owner_id);
  g_object_unref (test_cloud_provider);

  return 0;
}

07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!303 blocks
openSUSE Build Service is sponsored by