Full Code of holylobster/nuntius-linux for AI

master 265820d0bfd3 cached
45 files
130.3 KB
32.8k tokens
1 symbols
1 requests
Download .txt
Repository: holylobster/nuntius-linux
Branch: master
Commit: 265820d0bfd3
Files: 45
Total size: 130.3 KB

Directory structure:
gitextract_9d2x1sfm/

├── .tx/
│   └── config
├── AUTHORS
├── COPYING
├── Makefile.am
├── NEWS
├── README.md
├── autogen.sh
├── configure.ac
├── createcert.sh
├── data/
│   ├── icons/
│   │   └── render-bitmaps.rb
│   ├── org.holylobster.nuntius.appdata.xml.in
│   ├── org.holylobster.nuntius.desktop.in
│   ├── org.holylobster.nuntius.gschema.xml.in
│   └── org.holylobster.nuntius.service.in
├── git.mk
├── po/
│   ├── LINGUAS
│   ├── POTFILES.in
│   ├── POTFILES.skip
│   ├── de.po
│   ├── es.po
│   ├── pl.po
│   └── sk.po
├── src/
│   ├── application.vala
│   ├── appslist.vala
│   ├── appslistpanel.vala
│   ├── config.vapi
│   ├── connection.vala
│   ├── main.vala
│   ├── notification.vala
│   ├── notificationapp.vala
│   ├── notificationcounter.vala
│   ├── notificationsview.vala
│   ├── qrencode.vapi
│   ├── qrimage.vala
│   ├── resources/
│   │   ├── css/
│   │   │   └── nuntius-style.css
│   │   ├── gtk/
│   │   │   └── menus.ui
│   │   ├── nuntius.gresource.xml
│   │   └── ui/
│   │       ├── approw.ui
│   │       ├── appslistpanel.ui
│   │       ├── notificationcounter.ui
│   │       └── window.ui
│   ├── smsnotification.vala
│   ├── testview.vala
│   └── window.vala
└── tests/
    └── qrtest.vala

================================================
FILE CONTENTS
================================================

================================================
FILE: .tx/config
================================================
[main]
host = https://www.transifex.com
type = PO

[nuntius-linux.strings]
file_filter = po/<lang>.po
source_file = po/nuntius.pot
source_lang = en

================================================
FILE: AUTHORS
================================================
Andrea Curtoni <andreacurtoni@gmail.com>
Ignacio Casal Quinteiro <nacho.resa@gmail.com>
Paolo Borelli <pborelli@katamail.com>


================================================
FILE: COPYING
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the 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 Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

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

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.



================================================
FILE: Makefile.am
================================================
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}

SUBDIRS = po

# desktop file
desktopdir = $(datadir)/applications
desktop_in_files = data/org.holylobster.nuntius.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@

# autostart file
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = $(desktop_DATA)

# appdata file
appdatadir = $(datadir)/appdata
appdata_DATA = $(appdata_in_files:.xml.in=.xml)
appdata_in_files = data/org.holylobster.nuntius.appdata.xml.in
@INTLTOOL_XML_RULE@

# DBus service file
servicedir = $(datadir)/dbus-1/services
service_DATA = data/org.holylobster.nuntius.service
dist_noinst_DATA = data/org.holylobster.nuntius.service.in

data/org.holylobster.nuntius.service: data/org.holylobster.nuntius.service.in Makefile
	$(AM_V_GEN) $(MKDIR_P) $(dir $@); sed -e "s|\@bindir\@|$(bindir)|" $< > $@

# gsettings
gsettings_SCHEMAS = data/org.holylobster.nuntius.gschema.xml
@GSETTINGS_RULES@

data_icons_public_icons = \
	hicolor_apps_16x16_nuntius.png \
	hicolor_apps_22x22_nuntius.png \
	hicolor_apps_24x24_nuntius.png \
	hicolor_apps_32x32_nuntius.png \
	hicolor_apps_48x48_nuntius.png \
	hicolor_apps_256x256_nuntius.png

data-icons-install-icons:
	@echo "Installing icons"; \
	for icon in $(data_icons_public_icons); do \
		THEME=`echo $$icon | cut -d_ -f1`; \
		CONTEXT=`echo $$icon | cut -d_ -f2`; \
		SIZE=`echo $$icon | cut -d_ -f3`; \
		ICONFILE=`echo $$icon | cut -d_ -f4`; \
		$(mkinstalldirs) $(DESTDIR)$(datadir)/icons/$$THEME/$$SIZE/$$CONTEXT; \
		echo "  - $(DESTDIR)$(datadir)/icons/$$THEME/$$SIZE/$$CONTEXT/$$ICONFILE"; \
		$(INSTALL_DATA) $(srcdir)/data/icons/$$icon $(DESTDIR)$(datadir)/icons/$$THEME/$$SIZE/$$CONTEXT/$$ICONFILE; \
	done;

data-icons-uninstall-icons:
	-for icon in $(data_icons_public_icons); do \
		THEME=`echo $$icon | cut -d_ -f1`; \
		CONTEXT=`echo $$icon | cut -d_ -f2`; \
		SIZE=`echo $$icon | cut -d_ -f3`; \
		ICONFILE=`echo $$icon | cut -d_ -f4`; \
		rm -f $(DESTDIR)$(datadir)/icons/$$THEME/$$SIZE/$$CONTEXT/$$ICONFILE; \
	done;

AM_CPPFLAGS = \
	-DGETTEXT_PACKAGE=\""$(GETTEXT_PACKAGE)"\" \
	-DGNOMELOCALEDIR=\""$(localedir)"\" \
	-DDATADIR=\""$(datadir)"\" \
	-DTOOLSDIR=\""$(libexecdir)/$(PACKAGE)"\"

AM_VALAFLAGS = \
	--target-glib=2.40 \
	--pkg gio-2.0 \
	--pkg gio-unix-2.0 \
	--pkg gtk+-3.0 \
	--pkg json-glib-1.0 \
	--pkg posix \
	--gresources  $(top_srcdir)/src/resources/nuntius.gresource.xml

bin_PROGRAMS = nuntius qrtest

BUILT_SOURCES = \
	src/resources.c

resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(top_srcdir)/src/resources $(top_srcdir)/src/resources/nuntius.gresource.xml)
src/resources.c: $(top_srcdir)/src/resources/nuntius.gresource.xml $(resource_files)
	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/src/resources --generate-source $<

toolsdir = $(libexecdir)/$(PACKAGE)
tools_SCRIPTS = createcert.sh

VALA_SOURCES = \
	src/application.vala \
	src/appslistpanel.vala \
	src/appslist.vala \
	src/connection.vala \
	src/notification.vala \
	src/notificationapp.vala \
	src/notificationcounter.vala \
	src/notificationsview.vala \
	src/qrimage.vala \
	src/smsnotification.vala \
	src/testview.vala \
	src/window.vala \
	src/main.vala

nuntius_SOURCES = \
	$(BUILT_SOURCES) \
	$(VALA_SOURCES) \
	src/config.vapi \
	src/qrencode.vapi

AM_CFLAGS = \
	$(NUNTIUS_CFLAGS) \
	-Wall \
	-Wno-unused-but-set-variable \
	-Wno-unused-variable

nuntius_LDFLAGS = -export-dynamic
nuntius_LDADD = \
	$(NUNTIUS_LIBS) \
	-lm

qrtest_SOURCES = \
	tests/qrtest.vala \
	src/qrimage.vala \
	src/qrencode.vapi

qrtest_LDFLAGS = -export-dynamic
qrtest_LDADD = \
	$(NUNTIUS_LIBS) \
	-lm

check-local: $(desktop_DATA)
	$(DESKTOP_FILE_VALIDATE) $(desktop_DATA)

install-data-local: data-icons-install-icons

uninstall-local: data-icons-uninstall-icons

EXTRA_DIST = \
	$(appdata_in_files) \
	$(desktop_in_files) \
	$(resource_files) \
	src/resources/nuntius.gresource.xml \
	$(addprefix data/icons/,$(data_icons_public_icons))

CLEANFILES = \
	$(appdata_DATA) \
	$(desktop_DATA) \
	$(service_DATA)

MAINTAINERCLEANFILES = \
	ABOUT-NLS \
	aclocal.m4 \
	config.guess \
	config.h.in \
	config.rpath \
	config.sub \
	depcomp \
	install-sh \
	ltmain.sh \
	missing \
	compile \
	$(VALA_SOURCES:.vala=.c) \
	*.stamp

-include $(top_srcdir)/git.mk


================================================
FILE: NEWS
================================================
=============
nuntius 0.2.0
=============

New Features and Fixes
======================
- Added user interface
- Added translation support
- Misc bugfixes

=============
nuntius 0.1.0
=============

New Features and Fixes
======================
- Added appdata
- Added translation support
- Use DBusObjectManager instead of custom implementation
- Misc bugfixes

=============
nuntius 0.0.1
=============

Initial Release.


================================================
FILE: README.md
================================================
Nuntius
===================================

## Introduction
Nuntius delivers notifications from your phone or tablet to your computer over Bluetooth.

Nuntius is an Open Source project from HolyLobster.

To use Nuntius you will need to install a companion tool on your phone or tablet and pair it via Bluetooth.
You will also need to restart your session to auto-start nuntius.

For more information on the project and the companion tools to install on the computer check https://github.com/holylobster

## The Icon
You may have questions on the icon. Nice shot.
In fact most of the Nuntius development time has been spent on the icon design concept.
If you have suggestions on how to improve it we are very open... but... we think it is hardly possible to do better than this.

## Packages
You can install Nuntius from:

 * Fedora: `dnf install nuntius` (use `yum` instead of `dnf` on Fedora <= 21)
 * [Arch Linux (AUR)](https://aur.archlinux.org/packages/nuntius/)

You will need to install Nuntius also on your phone or tablet.

At the moment Nuntius is available for Android, check here

 * https://github.com/holylobster/nuntius-android

## Getting in touch
We have an IRC channel: #nuntius on the irc.gnome.org server.
Feel free to join and talk to us! Note that the channel is new and there are not many people (yet!) so be patient and hang around if you do not receive a reply immediately.

## Some tips to debug
 * Launch the bluetooth dameon as "sudo  /usr/libexec/bluetooth/bluetoothd -d -n"
 * Using bluetoothctl
   * I had to set "agent on", "default-agent" and "trust 98:D6:F7:73:03:F1"
   * Having it running it will provide some information
 * /var/log/messages gives also some information about bluetoothd if you do not run it directly
 * run "sudo btmon > btmon.log" to get information from the devices that try to connect to the computer
   * This is very useful to see to which uuid is trying to connect and what kind of errors it gets



================================================
FILE: autogen.sh
================================================
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

test -n "$srcdir" || srcdir=`dirname "$0"`
test -n "$srcdir" || srcdir=.

OLDDIR=`pwd`
cd $srcdir

AUTORECONF=`which autoreconf`
if test -z $AUTORECONF; then
    echo "*** No autoreconf found, please install it ***"
    exit 1
fi

INTLTOOLIZE=`which intltoolize`
if test -z $INTLTOOLIZE; then
    echo "*** No intltoolize found, please install the intltool package ***"
    exit 1
fi

git submodule update --init --recursive

autopoint --force || exit $?
AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose

cd $OLDDIR
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"


================================================
FILE: configure.ac
================================================
AC_PREREQ(2.63)

AC_INIT([nuntius], [0.2.0])

dnl http://people.gnome.org/~walters/docs/build-api.txt
dnl We don't support separate builddir when building from git
echo \#buildapi-variable-no-builddir >/dev/null

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_SRCDIR(src/main.vala)

AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip foreign])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])

IT_PROG_INTLTOOL([0.50.1])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.17])
GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST([GETTEXT_PACKAGE])
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])

AC_PROG_CC
AC_PROG_CC_STDC
AC_PROG_INSTALL
AM_PROG_VALAC([0.23.3])

AC_PATH_PROG(DESKTOP_FILE_VALIDATE, desktop-file-validate, /bin/true)
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)

GLIB_GSETTINGS

PKG_PROG_PKG_CONFIG

PKG_CHECK_MODULES(NUNTIUS, [
    gio-2.0 >= 2.40
    gio-unix-2.0 >= 2.38
    glib-2.0 >= 2.38
    gtk+-3.0 >= 3.14.0
    json-glib-1.0 >= 0.16.2
    libqrencode >= 3.1.0
])

AC_CONFIG_FILES([
    Makefile
    data/org.holylobster.nuntius.gschema.xml
    po/Makefile.in
])

AC_OUTPUT

echo "
    nuntius ${VERSION}

    prefix: ${prefix}
    Vala compiler: ${VALAC}
    C compiler: ${CC}

    Now type 'make' to build ${PACKAGE}
"


================================================
FILE: createcert.sh
================================================
#!/bin/bash

function try {
    "$@"
    local status=$?
    if [ $status -ne 0 ]; then
        echo -e "\nError with $1" >&2
        exit $?
    fi
    return $status
}

function create_cert() {
    if [[ ! -f $HOME/.config/nuntius/nuntius.pem || ! -f $HOME/.config/nuntius/nuntius.key ]]; then
        echo "Creating cert..."
        cd $HOME/.config/nuntius
        try openssl genrsa -out nuntius.key 2048
        try openssl req -new -key nuntius.key -out nuntius.csr -subj "/O=Holylobster/OU=Nuntius"
        try openssl x509 -req -days 3650 -in nuntius.csr -signkey nuntius.key -out nuntius.crt
        try openssl x509 -in nuntius.crt -out nuntius.pem
        exit $?
    else
        echo "Certificate already exist..."
        exit 0
    fi
}

if [[ ! -d $HOME/.config/nuntius ]]; then
    echo "Creating nuntius config directory..."
    mkdir -p $HOME/.config/nuntius
fi

create_cert

# ex:set ts=4 et:


================================================
FILE: data/icons/render-bitmaps.rb
================================================
#!/usr/bin/env ruby

require "rexml/document"
require "fileutils"
include REXML
INKSCAPE = '/usr/bin/inkscape'
SRC = "./"

def renderit(file,explicit)
  svg = Document.new(File.new("#{SRC}/#{file}", 'r'))
  #puts "DEBUG: #{file}"
  svg.root.each_element("//g[contains(@inkscape:label,'baseplate')]") do |icon|
    if icon.attributes['inkscape:groupmode']=='layer' #only look inside layers, there may be pasted groups
      context = icon.elements["text[@inkscape:label='context']/tspan"].nil? ? 'blank' : icon.elements["text[@inkscape:label='context']/tspan"].text
      icon_name = icon.elements["text[@inkscape:label='icon-name']/tspan"].nil? ? 'blank' : icon.elements["text[@inkscape:label='icon-name']/tspan"].text
      puts "#{file}:#{icon.attributes['inkscape:label']}  #{context}/#{icon_name}"
      icon.each_element("rect") do |box|
        dir = "hicolor/#{box.attributes['width']}x#{box.attributes['height']}/#{context}"
        out = "#{dir}/#{icon_name.gsub(/$/,'.png')}"
        cmd = "#{INKSCAPE} -i #{box.attributes['id']} -e #{out} #{SRC}/#{file} > /dev/null 2>&1"
        FileUtils.makedirs(dir) unless File.exists?(dir)
        if (!explicit && File.exists?(out))
          print "-" #skip if PNG exists
        elsif (box.attributes['width']=="256")
          system(cmd)
          print "."
          dir = "hicolor/512x512/#{context}"
          out = "#{dir}/#{icon_name.gsub(/$/,'.png')}"
          cmd = "#{INKSCAPE} -i #{box.attributes['id']} -d 180 -e #{out} #{SRC}/#{file} > /dev/null 2>&1"
          system(cmd)
          print "*"          
        else
          system(cmd)
          print "."
        end
      end
      puts ''
    end
  end
end

if (ARGV[0].nil?) #render all SVGs
  system("mkdir hicolor/") unless File.exists?('hicolor')
  puts "Rendering from SVGs in #{SRC}"
  Dir.foreach(SRC) do |file|
    renderit(file, false) if file.match(/svg$/)
  end
  puts "\nrendered all SVGs"
else #only render the SVG passed
  file = "#{ARGV[0]}.svg"
  if (File.exists?("#{SRC}/#{file}"))
    renderit(file, true)
    puts "\nrendered #{file}"
  else
    puts "[E] No such file (#{file})"
  end
end


================================================
FILE: data/org.holylobster.nuntius.appdata.xml.in
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2015 Ignacio Casal Quinteiro <icq@gnome.org> -->
<application>
  <id type="desktop">org.holylobster.nuntius.desktop</id>
  <metadata_license>CC0</metadata_license>
  <project_license>GPL-2.0+</project_license>
  <description>
    <_p>
      Nuntius delivers notifications from your phone or tablet to your computer
      over Bluetooth.
    </_p>
    <_p>
      To use Nuntius you will need to install a companion tool on your phone or
      tablet and pair it via Bluetooth.
    </_p>
  </description>
  <screenshots>
    <screenshot type="default">https://raw.githubusercontent.com/holylobster/nuntius-android/master/store-stuff/play-store-feature.jpg</screenshot>
  </screenshots>
  <url type="homepage">https://github.com/orgs/holylobster</url>
  <updatecontact>icq@gnome.org</updatecontact>
</application>


================================================
FILE: data/org.holylobster.nuntius.desktop.in
================================================
[Desktop Entry]
Name=Nuntius
GenericName=Nuntius
X-GNOME-FullName=Nuntius
_Comment=Deliver notifications from your phone or tablet to your computer over Bluetooth
_Keywords=notifications;
Exec=nuntius
Terminal=false
Type=Application
Icon=nuntius
Categories=GNOME;GTK;Utility;
StartupNotify=true
DBusActivatable=true
X-GNOME-Autostart-enabled=true
X-GNOME-UsesNotifications=true


================================================
FILE: data/org.holylobster.nuntius.gschema.xml.in
================================================
<schemalist gettext-domain="@GETTEXT_PACKAGE@">
  <schema id="org.holylobster.nuntius.state" path="/org/holylobster/nuntius/state/">
    <child schema="org.holylobster.nuntius.state.window" name="window"/>
  </schema>
  <schema id="org.holylobster.nuntius.state.window" path="/org/holylobster/nuntius/state/window/">
    <key type="i" name="state">
      <default>0</default>
      <summary>Window state</summary>
      <description>
        State of the window, e.g. maximized.
      </description>
    </key>
    <key type="(ii)" name="size">
      <default>(870, 690)</default>
      <summary>Window width and height</summary>
      <description>
        Width and height of the window.
      </description>
    </key>
  </schema>
</schemalist>


================================================
FILE: data/org.holylobster.nuntius.service.in
================================================
[D-BUS Service]
Name=org.holylobster.nuntius
Exec=@bindir@/nuntius --gapplication-service


================================================
FILE: git.mk
================================================
# git.mk
#
# Copyright 2009, Red Hat, Inc.
# Copyright 2010,2011,2012,2013 Behdad Esfahbod
# Written by Behdad Esfahbod
#
# Copying and distribution of this file, with or without modification,
# is permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
#
# The latest version of this file can be downloaded from:
GIT_MK_URL = https://raw.github.com/behdad/git.mk/master/git.mk
#
# Bugs, etc, should be reported upstream at:
#   https://github.com/behdad/git.mk
#
# To use in your project, import this file in your git repo's toplevel,
# then do "make -f git.mk".  This modifies all Makefile.am files in
# your project to -include git.mk.  Remember to add that line to new
# Makefile.am files you create in your project, or just rerun the
# "make -f git.mk".
#
# This enables automatic .gitignore generation.  If you need to ignore
# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
# But think twice before doing that.  If a file has to be in .gitignore,
# chances are very high that it's a generated file and should be in one
# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
#
# The only case that you need to manually add a file to GITIGNOREFILES is
# when remove files in one of mostlyclean-local, clean-local, distclean-local,
# or maintainer-clean-local make targets.
#
# Note that for files like editor backup, etc, there are better places to
# ignore them.  See "man gitignore".
#
# If "make maintainer-clean" removes the files but they are not recognized
# by this script (that is, if "git status" shows untracked files still), send
# me the output of "git status" as well as your Makefile.am and Makefile for
# the directories involved and I'll diagnose.
#
# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
# Makefile.am.sample in the git.mk git repo.
#
# Don't EXTRA_DIST this file.  It is supposed to only live in git clones,
# not tarballs.  It serves no useful purpose in tarballs and clutters the
# build dir.
#
# This file knows how to handle autoconf, automake, libtool, gtk-doc,
# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
# appstream.
#
# This makefile provides the following targets:
#
# - all: "make all" will build all gitignore files.
# - gitignore: makes all gitignore files in the current dir and subdirs.
# - .gitignore: make gitignore file for the current dir.
# - gitignore-recurse: makes all gitignore files in the subdirs.
#
# KNOWN ISSUES:
#
# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
#   submodule doesn't find us.  If you have configure.{in,ac} files in
#   subdirs, add a proxy git.mk file in those dirs that simply does:
#   "include $(top_srcdir)/../git.mk".  Add more ..'s to your taste.
#   And add those files to git.  See vte/gnome-pty-helper/git.mk for
#   example.
#



###############################################################################
# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
###############################################################################

#
# Most autotools-using modules should be fine including this variable in their
# toplevel MAINTAINERCLEANFILES:
GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
	$(srcdir)/aclocal.m4 \
	$(srcdir)/autoscan.log \
	$(srcdir)/configure.scan \
	`AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
	 test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
	 for x in \
		ar-lib \
		compile \
		config.guess \
		config.sub \
		depcomp \
		install-sh \
		ltmain.sh \
		missing \
		mkinstalldirs \
		test-driver \
		ylwrap \
	 ; do echo "$$AUX_DIR/$$x"; done` \
	`cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
	head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
#
# All modules should also be fine including the following variable, which
# removes automake-generated Makefile.in files:
GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
	`cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
	while read f; do \
	  case $$f in Makefile|*/Makefile) \
	    test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
	done`
#
# Modules that use libtool and use  AC_CONFIG_MACRO_DIR() may also include this,
# though it's harmless to include regardless.
GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
	`MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
	 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
		for x in \
			libtool.m4 \
			ltoptions.m4 \
			ltsugar.m4 \
			ltversion.m4 \
			lt~obsolete.m4 \
		; do echo "$$MACRO_DIR/$$x"; done; \
	 fi`



###############################################################################
# Default rule is to install ourselves in all Makefile.am files:
###############################################################################

git-all: git-mk-install

git-mk-install:
	@echo "Installing git makefile"
	@any_failed=; \
		find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
		if grep 'include .*/git.mk' $$x >/dev/null; then \
			echo "$$x already includes git.mk"; \
		else \
			failed=; \
			echo "Updating $$x"; \
			{ cat $$x; \
			  echo ''; \
			  echo '-include $$(top_srcdir)/git.mk'; \
			} > $$x.tmp || failed=1; \
			if test x$$failed = x; then \
				mv $$x.tmp $$x || failed=1; \
			fi; \
			if test x$$failed = x; then : else \
				echo "Failed updating $$x"; >&2 \
				any_failed=1; \
			fi; \
	fi; done; test -z "$$any_failed"

git-mk-update:
	wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk

.PHONY: git-all git-mk-install git-mk-update



###############################################################################
# Actual .gitignore generation:
###############################################################################

$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
	@echo "git.mk: Generating $@"
	@{ \
		if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
			for x in \
				$(DOC_MODULE)-decl-list.txt \
				$(DOC_MODULE)-decl.txt \
				tmpl/$(DOC_MODULE)-unused.sgml \
				"tmpl/*.bak" \
				xml html \
			; do echo "/$$x"; done; \
			FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
			case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
		fi; \
		if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
			for lc in $(DOC_LINGUAS); do \
				for x in \
					$(if $(DOC_MODULE),$(DOC_MODULE).xml) \
					$(DOC_PAGES) \
					$(DOC_INCLUDES) \
				; do echo "/$$lc/$$x"; done; \
			done; \
			for x in \
				$(_DOC_OMF_ALL) \
				$(_DOC_DSK_ALL) \
				$(_DOC_HTML_ALL) \
				$(_DOC_MOFILES) \
				$(DOC_H_FILE) \
				"*/.xml2po.mo" \
				"*/*.omf.out" \
			; do echo /$$x; done; \
		fi; \
		if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
			for lc in $(HELP_LINGUAS); do \
				for x in \
					$(HELP_FILES) \
					"$$lc.stamp" \
					"$$lc.mo" \
				; do echo "/$$lc/$$x"; done; \
			done; \
		fi; \
		if test "x$(gsettings_SCHEMAS)" = x; then :; else \
			for x in \
				$(gsettings_SCHEMAS:.xml=.valid) \
				$(gsettings__enum_file) \
			; do echo "/$$x"; done; \
		fi; \
		if test "x$(appdata_XML)" = x; then :; else \
			for x in \
				$(appdata_XML:.xml=.valid) \
			; do echo "/$$x"; done; \
		fi; \
		if test "x$(appstream_XML)" = x; then :; else \
			for x in \
				$(appstream_XML:.xml=.valid) \
			; do echo "/$$x"; done; \
		fi; \
		if test -f $(srcdir)/po/Makefile.in.in; then \
			for x in \
				po/Makefile.in.in \
				po/Makefile.in.in~ \
				po/Makefile.in \
				po/Makefile \
				po/Makevars.template \
				po/POTFILES \
				po/Rules-quot \
				po/stamp-it \
				po/.intltool-merge-cache \
				"po/*.gmo" \
				"po/*.header" \
				"po/*.mo" \
				"po/*.sed" \
				"po/*.sin" \
				po/$(GETTEXT_PACKAGE).pot \
				intltool-extract.in \
				intltool-merge.in \
				intltool-update.in \
			; do echo "/$$x"; done; \
		fi; \
		if test -f $(srcdir)/configure; then \
			for x in \
				autom4te.cache \
				configure \
				config.h \
				stamp-h1 \
				libtool \
				config.lt \
			; do echo "/$$x"; done; \
		fi; \
		if test "x$(DEJATOOL)" = x; then :; else \
			for x in \
				$(DEJATOOL) \
			; do echo "/$$x.sum"; echo "/$$x.log"; done; \
			echo /site.exp; \
		fi; \
		if test "x$(am__dirstamp)" = x; then :; else \
			echo "$(am__dirstamp)"; \
		fi; \
		if test "x$(LTCOMPILE)" = x -a "x$(LTCXXCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
			for x in \
				"*.lo" \
				".libs" "_libs" \
			; do echo "$$x"; done; \
		fi; \
		for x in \
			.gitignore \
			$(GITIGNOREFILES) \
			$(CLEANFILES) \
			$(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
			$(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
			$(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
			so_locations \
			$(MOSTLYCLEANFILES) \
			$(TEST_LOGS) \
			$(TEST_LOGS:.log=.trs) \
			$(TEST_SUITE_LOG) \
			"*.gcda" \
			"*.gcno" \
			$(DISTCLEANFILES) \
			$(am__CONFIG_DISTCLEAN_FILES) \
			$(CONFIG_CLEAN_FILES) \
			TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
			"*.tab.c" \
			$(MAINTAINERCLEANFILES) \
			$(BUILT_SOURCES) \
			$(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
			$(filter %_vala.stamp,$(DIST_COMMON)) \
			$(filter %.vapi,$(DIST_COMMON)) \
			$(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
			Makefile \
			Makefile.in \
			"*.orig" \
			"*.rej" \
			"*.bak" \
			"*~" \
			".*.sw[nop]" \
			".dirstamp" \
		; do echo "/$$x"; done; \
		for x in \
			"*.$(OBJEXT)" \
			$(DEPDIR) \
		; do echo "$$x"; done; \
	} | \
	sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
	sed 's@/[.]/@/@g' | \
	LC_ALL=C sort | uniq > $@.tmp && \
	mv $@.tmp $@;

all: $(srcdir)/.gitignore gitignore-recurse-maybe
gitignore: $(srcdir)/.gitignore gitignore-recurse

gitignore-recurse-maybe:
	@for subdir in $(DIST_SUBDIRS); do \
	  case " $(SUBDIRS) " in \
	    *" $$subdir "*) :;; \
	    *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
	  esac; \
	done
gitignore-recurse:
	@for subdir in $(DIST_SUBDIRS); do \
	    test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
	done

maintainer-clean: gitignore-clean
gitignore-clean:
	-rm -f $(srcdir)/.gitignore

.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe


================================================
FILE: po/LINGUAS
================================================
# nuntius translations
# please keep this list sorted alphabetically
de
es
pl
sk


================================================
FILE: po/POTFILES.in
================================================
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
data/org.holylobster.nuntius.appdata.xml.in
data/org.holylobster.nuntius.desktop.in
[type: gettext/gsettings]data/org.holylobster.nuntius.gschema.xml.in
src/application.vala
src/appslist.vala
[type: gettext/glade]src/resources/gtk/menus.ui
[type: gettext/glade]src/resources/ui/appslistpanel.ui
[type: gettext/glade]src/resources/ui/window.ui
src/smsnotification.vala


================================================
FILE: po/POTFILES.skip
================================================
# List of source files that should *not* be translated.
# Please keep this file sorted alphabetically.
src/application.c
src/appslist.c
src/smsnotification.c


================================================
FILE: po/de.po
================================================
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Raphael Guttenberger <raphaelguttenberger@gmail.com>, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: nuntius-linux\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-15 17:00+0200\n"
"PO-Revision-Date: 2015-03-11 18:29+0100\n"
"Last-Translator: Raphael Guttenberger <raphaelguttenberger@gmail.com>\n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:1
msgid ""
"Nuntius delivers notifications from your phone or tablet to your computer "
"over Bluetooth."
msgstr ""
"Nuntius sendet Benachrichtigungen von deinem Handy oder Tablet direkt an "
"deinen Computer über Bluetooth."

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:2
msgid ""
"To use Nuntius you will need to install a companion tool on your phone or "
"tablet and pair it via Bluetooth."
msgstr ""
"Um Nuntius zu benutzen, musst du ein Hilfstool auf deinem Handy oder Tablet "
"installieren und es über Bluetooth mit deinem PC verbinden."

#: ../data/org.holylobster.nuntius.desktop.in.h:1
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth"
msgstr ""
"Sende Benachrichtigungen von deinem Handy oder Tablet an deinen PC über "
"Bluetooth"

#: ../data/org.holylobster.nuntius.desktop.in.h:2
msgid "notifications;"
msgstr "Benachrichtigungen;"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:1
msgid "Window state"
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:2
msgid "State of the window, e.g. maximized."
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:3
msgid "Window width and height"
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:4
msgid "Width and height of the window."
msgstr ""

#: ../src/application.vala:144
msgid "Connect to a specific server"
msgstr ""

#: ../src/application.vala:297
msgid "Certificate Fingerprint"
msgstr ""

#: ../src/application.vala:300
msgid "_OK"
msgstr ""

#: ../src/application.vala:469 ../src/resources/ui/window.ui.h:1
msgid "Nuntius"
msgstr ""

#: ../src/application.vala:472
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth."
msgstr ""
"Sende Benachrichtigungen von deinem Handy oder Tablet an deinen PC über "
"Bluetooth."

#: ../src/application.vala:477
msgid "translator-credits"
msgstr "Raphael Guttenberger <raphaelguttenberger@gmail.com>, 2015"

#: ../src/appslist.vala:75
msgid "Blacklist this application"
msgstr ""

#. namespace Nuntius
#. ex:set ts=4 et:
#: ../src/resources/gtk/menus.ui.h:1
msgid "Show _QR Code"
msgstr ""

#: ../src/resources/gtk/menus.ui.h:2
msgid "_About"
msgstr ""

#: ../src/resources/ui/appslistpanel.ui.h:1
msgid "Type to search"
msgstr ""

#: ../src/resources/ui/window.ui.h:2
msgid "All Applications"
msgstr ""

#. FIXME: just a test message until we have UI to type the reply
#: ../src/smsnotification.vala:63
msgid "Reply"
msgstr ""


================================================
FILE: po/es.po
================================================
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Daniel Mustieles <daniel.mustieles@gmail.com>, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: nuntius-linux\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-15 17:00+0200\n"
"PO-Revision-Date: 2015-03-12 11:41+0100\n"
"Last-Translator: Daniel Mustieles <daniel.mustieles@gmail.com>\n"
"Language-Team: Español; Castellano <gnome-es-list@gnome.org>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:1
msgid ""
"Nuntius delivers notifications from your phone or tablet to your computer "
"over Bluetooth."
msgstr ""
"Nuntius envía notificaciones desde su teléfono o tableta a su equipo "
"mediante Bluetooth."

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:2
msgid ""
"To use Nuntius you will need to install a companion tool on your phone or "
"tablet and pair it via Bluetooth."
msgstr ""
"Para usar Nuntius deberá instalar una herramienta complementaria en su "
"teléfono o tableta y emparejarlo mediante Bluetooth."

#: ../data/org.holylobster.nuntius.desktop.in.h:1
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth"
msgstr ""
"Enviar notificaciones desde su teléfono o tableta a su equipo mediante "
"Bluetooth"

#: ../data/org.holylobster.nuntius.desktop.in.h:2
msgid "notifications;"
msgstr "notificaciones;"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:1
msgid "Window state"
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:2
msgid "State of the window, e.g. maximized."
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:3
msgid "Window width and height"
msgstr ""

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:4
msgid "Width and height of the window."
msgstr ""

#: ../src/application.vala:144
msgid "Connect to a specific server"
msgstr ""

#: ../src/application.vala:297
msgid "Certificate Fingerprint"
msgstr ""

#: ../src/application.vala:300
msgid "_OK"
msgstr ""

#: ../src/application.vala:469 ../src/resources/ui/window.ui.h:1
msgid "Nuntius"
msgstr ""

#: ../src/application.vala:472
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth."
msgstr ""
"Enviar notificaciones desde su teléfono o tableta a su equipo mediante "
"Bluetooth."

#: ../src/application.vala:477
msgid "translator-credits"
msgstr "Daniel Mustieles <daniel.mustieles@gmail.com>, 2015"

#: ../src/appslist.vala:75
msgid "Blacklist this application"
msgstr ""

#. namespace Nuntius
#. ex:set ts=4 et:
#: ../src/resources/gtk/menus.ui.h:1
msgid "Show _QR Code"
msgstr ""

#: ../src/resources/gtk/menus.ui.h:2
msgid "_About"
msgstr ""

#: ../src/resources/ui/appslistpanel.ui.h:1
msgid "Type to search"
msgstr ""

#: ../src/resources/ui/window.ui.h:2
msgid "All Applications"
msgstr ""

#. FIXME: just a test message until we have UI to type the reply
#: ../src/smsnotification.vala:63
msgid "Reply"
msgstr ""


================================================
FILE: po/pl.po
================================================
# Polish translation for nuntius-linux.
# Copyright © 2015-2016 the nuntius-linux authors.
# This file is distributed under the same license as the nuntius-linux package.
# Piotr Drąg <piotrdrag@gmail.com>, 2015-2016.
# Aviary.pl <community-poland@mozilla.org>, 2015-2016.
#
msgid ""
msgstr ""
"Project-Id-Version: nuntius-linux\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-29 18:54+0200\n"
"PO-Revision-Date: 2016-08-29 18:55+0200\n"
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
"Language-Team: Polish <community-poland@mozilla.org>\n"
"Language: pl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n"

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:1
msgid ""
"Nuntius delivers notifications from your phone or tablet to your computer "
"over Bluetooth."
msgstr ""
"Nuntius wyświetla powiadomienia z telefonu lub tabletu na komputerze za "
"pomocą Bluetooth."

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:2
msgid ""
"To use Nuntius you will need to install a companion tool on your phone or "
"tablet and pair it via Bluetooth."
msgstr ""
"Aby użyć programu Nuntius, należy zainstalować uzupełniające narzędzie na "
"telefonie lub tablecie i połączyć je z komputerem za pomocą Bluetooth."

#: ../data/org.holylobster.nuntius.desktop.in.h:1
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth"
msgstr ""
"Wyświetlanie powiadomień z telefonu lub tabletu na komputerze za pomocą "
"Bluetooth"

#: ../data/org.holylobster.nuntius.desktop.in.h:2
msgid "notifications;"
msgstr ""
"powiadomienia;powiadamianie;notyfikacje;wiadomości;komunikaty;telefon;tablet;"
"smartfon;phablet;fablet;android;"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:1
msgid "Window state"
msgstr "Stan okna"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:2
msgid "State of the window, e.g. maximized."
msgstr "Stan okna, tzn. czy jest zmaksymalizowane."

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:3
msgid "Window width and height"
msgstr "Szerokość i wysokość okna"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:4
msgid "Width and height of the window."
msgstr "Szerokość i wysokość okna."

#: ../src/application.vala:144
msgid "Connect to a specific server"
msgstr "Łączy z podanym serwerem"

#: ../src/application.vala:297
msgid "Certificate Fingerprint"
msgstr "Odcisk certyfikatu"

#: ../src/application.vala:300
msgid "_OK"
msgstr "_OK"

#: ../src/application.vala:469 ../src/resources/ui/window.ui.h:1
msgid "Nuntius"
msgstr "Nuntius"

#: ../src/application.vala:472
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth."
msgstr ""
"Wyświetlanie powiadomień z telefonu lub tabletu na komputerze za pomocą "
"Bluetooth."

#: ../src/application.vala:477
msgid "translator-credits"
msgstr ""
"Piotr Drąg <piotrdrag@gmail.com>, 2015-2016\n"
"Aviary.pl <community-poland@mozilla.org>, 2015-2016"

#: ../src/appslist.vala:75
msgid "Blacklist this application"
msgstr "Dodaj program do czarnej listy"

#. namespace Nuntius
#. ex:set ts=4 et:
#: ../src/resources/gtk/menus.ui.h:1
msgid "Show _QR Code"
msgstr "Wyświetl kod _QR"

#: ../src/resources/gtk/menus.ui.h:2
msgid "_About"
msgstr "_O programie"

#: ../src/resources/ui/appslistpanel.ui.h:1
msgid "Type to search"
msgstr "Wyszukiwanie"

#: ../src/resources/ui/window.ui.h:2
msgid "All Applications"
msgstr "Wszystkie programy"

#. FIXME: just a test message until we have UI to type the reply
#: ../src/smsnotification.vala:63
msgid "Reply"
msgstr "Odpowiedz"


================================================
FILE: po/sk.po
================================================
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Dušan Kazik <prescott66@gmail.com>, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: nuntius-linux\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-15 17:00+0200\n"
"PO-Revision-Date: 2015-03-20 18:28+0100\n"
"Last-Translator: Dušan Kazik <prescott66@gmail.com>\n"
"Language-Team: \n"
"Language: sk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:1
msgid ""
"Nuntius delivers notifications from your phone or tablet to your computer "
"over Bluetooth."
msgstr ""
"Nuntius doručí oznámenia z vášho telefónu alebo tabletu do vášho počítača "
"cez Bluetooth."

#: ../data/org.holylobster.nuntius.appdata.xml.in.h:2
msgid ""
"To use Nuntius you will need to install a companion tool on your phone or "
"tablet and pair it via Bluetooth."
msgstr ""
"Na používanie programu Nuntius budete musieť vo vašom telefóne alebo tablete "
"nainštalovať spoločný nástroj a spárovať ho cez Bluetooth."

#: ../data/org.holylobster.nuntius.desktop.in.h:1
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth"
msgstr ""
"Doručenie oznámení z vášho telefónu alebo tabletu do vášho počítača cez "
"Bluetooth"

#: ../data/org.holylobster.nuntius.desktop.in.h:2
msgid "notifications;"
msgstr "oznámenia;upozornenia;"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:1
msgid "Window state"
msgstr "Stav okna"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:2
msgid "State of the window, e.g. maximized."
msgstr "Stav okna, napr. maximalizované."

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:3
msgid "Window width and height"
msgstr "Šírka a výška okna"

#: ../data/org.holylobster.nuntius.gschema.xml.in.h:4
msgid "Width and height of the window."
msgstr "Šírka a výška okna."

#: ../src/application.vala:144
msgid "Connect to a specific server"
msgstr ""

#: ../src/application.vala:297
msgid "Certificate Fingerprint"
msgstr ""

#: ../src/application.vala:300
msgid "_OK"
msgstr ""

#: ../src/application.vala:469 ../src/resources/ui/window.ui.h:1
msgid "Nuntius"
msgstr "Nuntius"

#: ../src/application.vala:472
msgid ""
"Deliver notifications from your phone or tablet to your computer over "
"Bluetooth."
msgstr ""
"Doručenie oznámení z vášho telefónu alebo tabletu do vášho počítača cez "
"Bluetooth."

#: ../src/application.vala:477
msgid "translator-credits"
msgstr "Dušan Kazik <prescott66@gmail.com>, 2015"

#: ../src/appslist.vala:75
#, fuzzy
msgid "Blacklist this application"
msgstr "Všetky aplikácie"

#. namespace Nuntius
#. ex:set ts=4 et:
#: ../src/resources/gtk/menus.ui.h:1
msgid "Show _QR Code"
msgstr ""

#: ../src/resources/gtk/menus.ui.h:2
msgid "_About"
msgstr "_O programe"

#: ../src/resources/ui/appslistpanel.ui.h:1
msgid "Type to search"
msgstr "Text na vyhľadanie"

#: ../src/resources/ui/window.ui.h:2
msgid "All Applications"
msgstr "Všetky aplikácie"

#. FIXME: just a test message until we have UI to type the reply
#: ../src/smsnotification.vala:63
msgid "Reply"
msgstr ""


================================================
FILE: src/application.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

[DBus (name = "org.bluez.Device1")]
public interface BluezDeviceBus : Object {
    public abstract async void connect_profile(string UUID) throws DBusError, IOError;
    public abstract void disconnect_profile(string UUID) throws DBusError, IOError;

    public abstract string name { owned get; }
    public abstract bool paired { owned get; }
    public abstract string[] uuids { owned get; }
}

[DBus (name = "org.bluez.ProfileManager1")]
public interface BluezProfileManager : Object {
    public abstract void register_profile(ObjectPath profile, string uuid, HashTable<string, Variant> options) throws IOError;

    public abstract void unregister_profile(ObjectPath profile) throws IOError;
}

public class Connections : Object {
    private HashTable<string, Connection>? connections;

    construct {
        connections = new HashTable<string, Connection>(str_hash, str_equal);
    }

    public void add_connection(Connection connection) {
        connections.insert(connection.server_name, connection);
        connection.notify["connected"].connect(() => {
            if (!connection.connected) {
                connections.remove(connection.server_name);
                print("removed connection for device '%s'\n",
                      connection.server_name);
            }
        });

        connection.notification_posted.connect((notification) => {
            var app = (Application) GLib.Application.get_default();
            app.add_notification(notification);
        });

        connection.sms_received.connect((sms_notification) => {
            var app = (Application) GLib.Application.get_default();
            app.add_sms_notification(sms_notification);
        });

        connection.notification_removed.connect((id, package_name) => {
            var app = (Application) GLib.Application.get_default();
            app.mark_notification_read(id, package_name);
        });
    }

    public void remove_connection(string server_name) {
        var connection = connections.lookup(server_name);
        if (connection != null) {
            connections.remove(server_name);
        }
    }

    public bool is_connected() {
        return connections.size() > 0;
    }

    public bool get_connected(string server_name) {
        return connections.get(server_name) != null;
    }
}

[DBus (name = "org.bluez.Profile1")]
public class BluezProfile : Object {
    private Connections connections;

    public BluezProfile(Connections connections) {
        this.connections = connections;
    }

    public void release() {
        print("release method called\n");
    }

    public void new_connection(ObjectPath device, Socket socket, HashTable<string, Variant> fd_properties) {
        print("new_connection method called for device: %s\n", device);
        var connection = new Connection(device,
                                        SocketConnection.factory_create_connection(socket));

        connections.add_connection(connection);
    }

    public void request_disconnection(ObjectPath device) {
        print("request_disconnection method called for devices: %s\n", device);

        connections.remove_connection(device);
    }
}

private enum TcpConnectionStatus {
    DISCONNECTED,
    CONNECTING,
    CONNECTED
}

public class Application : Gtk.Application {
    private Cancellable? cancellable;
    private Connections connections;
    private DBusObjectManager manager;
    private BluezProfileManager? profile_manager;
    private BluezProfile? profile;
    private uint connect_devices_id;
    private bool first_activation;
    private bool cert_created;
    private Window window;
    private string connect_host;
    private TcpConnectionStatus tcp_status;
    private TlsCertificate? cert;
    private List<NotificationApp> _notification_apps;
    private List<SmsNotification> sms_notifications;

    private const GLib.ActionEntry[] app_entries = {
        { "about", on_about_activate },
        { "show-qrcode", on_show_qrcode_activate },
        { "open-notifications-view", on_open_notifications_view_activate, "(ss)"},
        { "send-sms", on_send_sms_activate, "(ss)"}
    };

    private const OptionEntry[] options = {
        {"connect", '\0', 0, OptionArg.STRING, null,
         N_("Connect to a specific server"), null},
        {null}
    };

    public signal void notification_app_added(NotificationApp notification_app);

    public List<NotificationApp> notification_apps {
        get { return _notification_apps; }
    }

    public Application() {
        Object(application_id: "org.holylobster.nuntius",
               flags: ApplicationFlags.HANDLES_COMMAND_LINE);
        add_main_option_entries(options);
    }

    construct {
        cancellable = new Cancellable();
        cert_created = false;
        first_activation = true;
        tcp_status = TcpConnectionStatus.DISCONNECTED;
        _notification_apps = new List<NotificationApp>();
    }

    protected override void dispose() {
        if (cancellable != null) {
            cancellable.cancel();
            cancellable = null;
        }

        if (connect_devices_id != 0) {
            Source.remove(connect_devices_id);
            connect_devices_id = 0;
        }

        base.dispose();
    }

    protected override void startup() {
        base.startup();

        // Since it works as a daemon keep a hold forever on the primary instance
        hold();

        add_action_entries(app_entries, this);

        var css_provider = new Gtk.CssProvider();
        try {
            var file = File.new_for_uri("resource:///org/holylobster/nuntius/css/nuntius-style.css");
            css_provider.load_from_file(file);
        } catch (Error e) {
            warning("loading css: %s", e.message);
        }
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                                 css_provider,
                                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

        connections = new Connections();
        profile = new BluezProfile(connections);

        var profile_path = new ObjectPath(get_dbus_object_path() + "/Profile");

        try {
            var conn = Bus.get_sync(BusType.SYSTEM);
            conn.register_object(profile_path, profile);

            profile_manager = Bus.get_proxy_sync(BusType.SYSTEM, "org.bluez", "/org/bluez");
            print("obtained bluez profile manager\n");

            var options = new HashTable<string, Variant>(str_hash, str_equal);
            options.insert("Role", new Variant.string("client"));

            profile_manager.register_profile(profile_path, "00001101-0000-1000-8000-00805f9b34fb", options);
            print("profile registered\n");

            manager = new DBusObjectManagerClient.for_bus_sync(BusType.SYSTEM, DBusObjectManagerClientFlags.NONE,
                                                               "org.bluez", "/", null, null);
            print("obtained bluez proxy\n");

            handle_managed_objects.begin(true);

            // check interfaces added dynamically
            manager.interface_added.connect(interface_added);
            manager.interface_removed.connect(interface_removed);
        } catch (Error e) {
            warning("%s", e.message);
        }

        create_cert();
    }

    private void ensure_window() {
        if (window == null) {
            window = new Window(this);
            window.destroy.connect(() => {
                window = null;
            });
        }
    }

    private string? spawn_command(string[] args) {
        try {
            string[] spawn_args = args;
            string[] spawn_env = Environ.get ();
            string ls_stdout;
            string ls_stderr;
            int ls_status;

            Process.spawn_sync (".",
                                spawn_args,
                                spawn_env,
                                SpawnFlags.SEARCH_PATH,
                                null,
                                out ls_stdout,
                                out ls_stderr,
                                out ls_status);
            return ls_stdout;

        } catch (SpawnError e) {
            stdout.printf ("Error: %s\n", e.message);
            return null;
        }
    }

    private void create_cert() {
        var path_to_conf = GLib.Path.build_filename(GLib.Environment.get_user_config_dir(), "nuntius");
        var cert_path = GLib.Path.build_filename(path_to_conf, "nuntius.pem");
        var key_path = GLib.Path.build_filename(path_to_conf, "nuntius.key");
        var file = File.new_for_path(cert_path);
        if (!file.query_exists()) {
            var script = GLib.Path.build_filename(Config.TOOLSDIR, "createcert.sh");
            string[] spawn_args = { script };
            spawn_command(spawn_args);
            cert_created = true;
        }
        try {
            cert = new TlsCertificate.from_files(cert_path, key_path);
        } catch (Error e) {
            warning("Failed to load certificate: %s", e.message);
        }
    }

    private string get_fingerprint() {
        string path_to_pem = GLib.Path.build_filename(GLib.Environment.get_user_config_dir(), "nuntius/nuntius.pem");
        string[] spawn_args = {"openssl", "x509", "-in", path_to_pem, "-fingerprint", "-sha1"};
        string result = spawn_command(spawn_args);
        string[] splitted = result.split("=");
        splitted = splitted[1].split("\n");
        string fingerprint = splitted[0];
        return fingerprint;
    }

    private void show_qrcode() {
        var dialog = new Gtk.Dialog.with_buttons(_("Certificate Fingerprint"),
                                                 window,
                                                 Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                                                 _("_OK"),
                                                 Gtk.ResponseType.OK);
        dialog.border_width = 30;
        dialog.set_default_size(300, 300);

        dialog.response.connect(i => {
            window.destroy();
        });

        var qr = new Nuntius.QRImage();
        qr.text = get_fingerprint() + "-" + GLib.Environment.get_host_name();
        qr.show();

        dialog.get_content_area().pack_end(qr, true, true, 0);
        dialog.show();
    }

    protected override void activate() {
        // We want it to start as a daemon and not showing the window from
        // the beginning
        if (!first_activation) {
            ensure_window();
            window.present();
            if (cert_created) {
                show_qrcode();
            }
        }

        first_activation = false;

        if (tcp_status == TcpConnectionStatus.DISCONNECTED && connect_host != null && cert != null) {
            var host = connect_host;
            var client = new SocketClient();

            tcp_status = TcpConnectionStatus.CONNECTING;

            client.tls = true;
            client.event.connect(on_socket_client_event);
            client.connect_to_host_async.begin(connect_host, 12233, cancellable, (obj, res) => {
                try {
                    var connection = client.connect_to_host_async.end(res);
                    tcp_status = TcpConnectionStatus.CONNECTED;
                    connections.add_connection(new Connection(host, connection));
                } catch (Error e) {
                    tcp_status = TcpConnectionStatus.DISCONNECTED;
                    warning("Could not connect to server: %s", connect_host);
                }
            });
        }

        base.activate();
    }

    private void on_socket_client_event(SocketClientEvent event, SocketConnectable? connectable, IOStream? ios) {
        if (event == SocketClientEvent.TLS_HANDSHAKING) {
            var tls = (TlsConnection) ios;
            tls.accept_certificate.connect((cert, err) => {
                return true;
            });
            tls.set_certificate(cert);
        }
    }

    protected override int command_line(ApplicationCommandLine cl) {
        var dict = cl.get_options_dict();

        dict.lookup("connect", "s", out connect_host);
        activate();

        return 0;
    }

    private async void connect_interface(DBusObject object, DBusInterface iface, bool dump) {
        if (!(iface is DBusProxy)) {
            return;
        }

        var name = (iface as DBusProxy).get_interface_name();
        var path = new ObjectPath(object.get_object_path());

        if (dump) {
            if (!name.has_prefix("org.freedesktop.DBus")) {
                print("added: [%s]\n", path);
                print("  %s\n", name);
            }
        }

        // try to get the device
        if (name == "org.bluez.Device1" && !connections.get_connected(path)) {
            try {
                BluezDeviceBus device = Bus.get_proxy_sync(BusType.SYSTEM, "org.bluez", path);

                if (device.paired) {
                    print("connect device: %s\n", device.name);
                    try {
                        yield device.connect_profile("00001101-0000-1000-8000-00805f9b34fb");
                    } catch (Error e) {
                        warning("Error connecting to device '%s': %s", device.name, e.message);
                    }
                }
            } catch (Error e) {
                warning("%s", e.message);
            }
        }
    }

    private void interface_added(DBusObjectManager manager, DBusObject object, DBusInterface iface) {
        connect_interface.begin(object, iface, true);
    }

    private void interface_removed(DBusObjectManager manager, DBusObject object, DBusInterface iface) {
        print("removed: [%s]\n", object.get_object_path());
        print("  %s\n", iface.get_info().name);
    }

    private async void handle_managed_objects(bool dump) {
        var objects = manager.get_objects();

        foreach (DBusObject o in objects) {
            foreach (DBusInterface iface in o.get_interfaces()) {
                yield connect_interface(o, iface, dump);
            }
        }

        if (!connections.is_connected()) {
            // try to connect to the paired device every few seconds
            connect_devices_id = Timeout.add_seconds(5, on_try_to_connect_devices);
        }
    }

    private bool on_try_to_connect_devices() {
        connect_devices_id = 0;
        handle_managed_objects.begin(false);

        return false;
    }

    public void on_open_notifications_view_activate(GLib.SimpleAction action, GLib.Variant? parameter) {
        string id, package_name;
        parameter.get("(ss)", out id, out package_name);

        Notification? notification = null;
        notification = get_notification(id, package_name);
        if (notification == null) {
            return;
        }

        /* FIXME: just temporary until we add actions to the main UI */
        if (notification.actions != null) {
            var view = new TestView(notification);
            view.show_all();
            return;
        }

        /* FIXME for now just raise the main window */
        activate();
    }

    private void on_about_activate() {
        const string copyright = "Copyright \xc2\xa9 2015 Holy Lobster Team";

        const string authors[] = {
            "Andrea Curtoni <andrea.curtoni@gmail.com>",
            "Ignacio Casal Quinteiro <icq@gnome.org>",
            "Paolo Borelli <pborelli@gnome.org>",
            null
        };

        Gtk.show_about_dialog(window,
                              "program-name", _("Nuntius"),
                              "logo-icon-name", "nuntius",
                              "version", Config.VERSION,
                              "comments", _("Deliver notifications from your phone or tablet to your computer over Bluetooth."),
                              "copyright", copyright,
                              "authors", authors,
                              "license-type", Gtk.License.GPL_2_0,
                              "wrap-license", false,
                              "translator-credits", _("translator-credits"),
                              null);
    }

    private void on_show_qrcode_activate() {
        show_qrcode();
    }

    public Notification? get_notification(string id, string package_name) {
        foreach (var napp in notification_apps) {
            if (napp.id == package_name) {
                var notification = napp.get_notification(id);
                if (notification != null) {
                    return notification;
                }
            }
        }
        return null;
    }

    public void add_notification(Notification notification) {
        bool found = false;

        foreach (var napp in _notification_apps) {
            if (napp.id == notification.package_name) {
                napp.add_notification(notification);
                found = true;
                break;
            }
        }

        if (!found) {
            var napp = new NotificationApp(notification.package_name, notification.connection);
            napp.add_notification(notification);
            _notification_apps.prepend(napp);

            notification_app_added(napp);
        }

        send_notification(notification.id,
                          notification.to_gnotification());
    }

    public void mark_notification_read(string id, string package_name) {
        Notification? notification = null;

        notification = get_notification(id, package_name);

        if (notification != null) {
            withdraw_notification(notification.id);
            notification.read = true;
        }
    }

    public void blacklist_application(string package_name) {
        foreach (var napp in notification_apps) {
            if (napp.id == package_name) {
                napp.blacklist();
            }
        }
    }

    public SmsNotification? get_sms_notification(string id) {
        foreach (var sms_notification in sms_notifications) {
            if (sms_notification.id == id) {
                return sms_notification;
            }
        }
        return null;
    }

    public void add_sms_notification(SmsNotification sms_notification) {
        sms_notifications.prepend(sms_notification);
        send_notification(sms_notification.id, sms_notification.to_gnotification());
    }

    public void on_send_sms_activate(GLib.SimpleAction action, GLib.Variant? parameter) {
        string id, text;
        parameter.get("(ss)", out id, out text);

        if (id != null && text != null) {
            var sms_notification = get_sms_notification(id);

            if (sms_notification != null) {
                sms_notification.send_sms_message(text);
            }
        }
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/appslist.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class AppsList : Gtk.ListBox {
    [GtkTemplate (ui = "/org/holylobster/nuntius/ui/approw.ui")]
    public class AppRow : Gtk.ListBoxRow {
        [GtkChild]
        private Gtk.Image image;
        [GtkChild]
        private Gtk.Label label;
        [GtkChild]
        private NotificationCounter notification_counter;
        private Gtk.Menu menu;

        private NotificationApp _notification_app;

        public NotificationApp notification_app {
            get { return _notification_app; }
            set construct { _notification_app = value; }
        }

        public AppRow(NotificationApp notification_app) {
            Object(notification_app: notification_app);

            image.set_from_gicon(notification_app.icon, Gtk.IconSize.BUTTON);
            notification_app.bind_property("unread-notifications",
                                           notification_counter,
                                           "counter",
                                           BindingFlags.SYNC_CREATE);

            if (notification_app.unread_notifications > 0) {
                notification_counter.show();
                label.set_markup("<b>" + notification_app.app_name + "</b>");
            } else {
                label.set_label(notification_app.app_name);
            }

            notification_app.notify["app-name"].connect(() => {
                image.set_from_gicon(notification_app.icon, Gtk.IconSize.BUTTON);
            });

            notification_app.notify["icon"].connect(() => {
                label.set_label(notification_app.app_name);
            });

            notification_app.notify["unread-notifications"].connect(() => {
                notification_counter.set_visible(notification_app.unread_notifications > 0);

                if (notification_app.unread_notifications > 0) {
                    label.set_markup("<b>" + notification_app.app_name + "</b>");
                } else {
                    label.set_label(notification_app.app_name);
                }
            });
        }

        public void show_popup_menu(Gdk.EventButton event) {
            menu = new Gtk.Menu();
            var item = new Gtk.MenuItem.with_label (_("Blacklist this application"));
            item.activate.connect(() => {
                notification_app.blacklist();
            });
            menu.append(item);
            menu.show_all();
            menu.popup(null, null, null, event.button, event.get_time());
        }
    }

    private string? filter_text;

    public signal void selection_changed(NotificationApp? notification_app);

    construct {
        set_header_func(update_header);
        set_filter_func(filter);

        /* FIXME: get the napps as a property to not depend on the app? */
        var app = GLib.Application.get_default() as Application;

        foreach (var napp in app.notification_apps) {
            var row = new AppRow(napp);
            add(row);
        }

        app.notification_app_added.connect((napp) => {
            var row = new AppRow(napp);
            add(row);
        });

        button_press_event.connect((event) => {
            if (event.type == Gdk.EventType.BUTTON_PRESS &&
                event.button == Gdk.BUTTON_SECONDARY) {
                print("button press right click\n");
                unselect_all();

                var row = get_row_at_y((int) event.y) as AppRow;
                if (row != null) {
                    select_row(get_row_at_y((int) event.y));
                    row.show_popup_menu(event);
                }

                return true;
            }

            return false;
        });
    }

    private void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before) {
        row.set_header(before != null ? new Gtk.Separator(Gtk.Orientation.HORIZONTAL) : null);
    }

    private bool filter(Gtk.ListBoxRow row) {
        return filter_text != null ? ((AppRow)row).notification_app.app_name.down().contains(filter_text) : true;
    }

    public override void row_selected(Gtk.ListBoxRow? row) {
        var app_row = row as AppRow;
        var notification_app = app_row != null ? app_row.notification_app : null;

        selection_changed(notification_app);
    }

    public void set_filter_text(string text) {
        filter_text = text.down();

        invalidate_filter();
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/appslistpanel.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

[GtkTemplate (ui = "/org/holylobster/nuntius/ui/appslistpanel.ui")]
public class AppsListPanel : Gtk.Frame {
    private uint filter_entry_changed_id;

    [GtkChild]
    private Gtk.ToolItem search_tool_item;

    [GtkChild]
    private Gtk.SearchEntry filter_entry;

    [GtkChild]
    private AppsList apps_list_view;

    public void refilter() {
        string str = filter_entry.get_text();

        apps_list_view.set_filter_text(str);
    }

    private bool filter_entry_changed_timeout() {
        filter_entry_changed_id = 0;
        refilter();
        return false;
    }

    [GtkCallback]
    private void filter_entry_changed(Gtk.Editable editable) {
        if (filter_entry_changed_id != 0) {
            Source.remove(filter_entry_changed_id);
        }

        filter_entry_changed_id = Timeout.add(300, filter_entry_changed_timeout);
    }

    public signal void selection_changed(NotificationApp? notification_app);

    construct {
        search_tool_item.set_expand(true);

        apps_list_view.selection_changed.connect((napp) => {
            selection_changed(napp);
        });
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/config.vapi
================================================
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
namespace Config {
    public const string VERSION;
    public const string DATADIR;
    public const string GETTEXT_PACKAGE;
    public const string GNOMELOCALEDIR;
    public const string TOOLSDIR;
}



================================================
FILE: src/connection.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class Connection : Object {
    private Cancellable cancellable;
    private SocketConnection? _connection;
    private DataInputStream? input;
    private DataOutputStream? output;
    private bool _connected;
    private string _server_name;

    public bool connected {
        get { return _connected; }
        set { _connected = value; }
    }

    public string server_name {
        get { return _server_name; }
        set construct { _server_name = value; }
    }

    public SocketConnection? connection {
        get { return _connection; }
        set construct { _connection = value; }
    }

    public signal void notification_posted(Notification notification);

    public signal void sms_received(SmsNotification notification);

    public signal void notification_removed(string id, string package_name);

    public Connection(string server_name, SocketConnection connection) {
        Object(connected: true, server_name: server_name, connection: connection);

        input = new DataInputStream(_connection.get_input_stream());
        input.set_newline_type(DataStreamNewlineType.CR_LF);
        output = new DataOutputStream(_connection.get_output_stream());
        read_message();
    }

    construct {
        cancellable = new Cancellable();
    }

    protected override void dispose() {
        if (cancellable != null) {
            cancellable.cancel();
            cancellable = null;
        }

        input = null;
        connection = null;

        base.dispose();
    }

    public void send_message(string msg) {
        try {
            output.put_string(msg + "\n");
        } catch (Error e) {
            print("Couldn't send message to " + _server_name);
        }
        print(msg);
    }

    void read_message() {
        input.read_line_async.begin(Priority.DEFAULT, cancellable, (obj, res) => {
            try {
                string notification_json = input.read_line_async.end(res);

                print("Got the json message: %s\n", notification_json);

                var parser = new Json.Parser();
                try {
                    parser.load_from_data(notification_json, -1);
                } catch (Error e) {
                    warning("There was a problem parsing the notification data: %s",
                            e.message);
                    read_message();
                    return;
                }

                var event = parser.get_root().get_object().get_string_member("event");
                var eventItems = parser.get_root().get_object().get_array_member("eventItems").get_elements();

                switch (event) {
                case "deviceConnected":
                    foreach (var i in eventItems) {
                        var object = i.get_object();
                        var name = object.get_string_member("name");
                        print("Device '%s' connected\n", name);
                    }
                    break;
                case "notificationPosted":
                    foreach (var i in eventItems) {
                        Notification? notification = null;
                        string? key = null;

                        var object = i.get_object();
                        var id = object.get_int_member("id").to_string();
                        var package_name = object.get_string_member("packageName");
                        var app_name = object.get_string_member("appName");

                        BytesIcon icon = null;
                        if (object.has_member("icon")) {
                            icon = new BytesIcon(new Bytes(Base64.decode(object.get_string_member("icon"))));
                        }

                        if (object.has_member("key")) {
                            key = object.get_string_member("key");
                        }

                        var notification_object = object.get_object_member("notification");
                        if (notification_object.has_member("title")) {
                            var title = notification_object.get_string_member("title");
                            string? text = null;
                            string? flags = null;
                            string[]? actions_string = null;

                            if (notification_object.has_member("flags")) {
                                flags = notification_object.get_string_member("flags");
                            }

                            if (notification_object.has_member("text")) {
                                text = notification_object.get_string_member("text");
                            }

                            if (notification_object.has_member("actions")) {
                                var actions = notification_object.get_array_member("actions").get_elements();
                                var number_of_actions = notification_object.get_array_member("actions").get_length();
                                actions_string = new string[number_of_actions];
                                var count = 0;
                                foreach (var action in actions) {
                                    actions_string[count] = action.get_object().get_string_member("title");
                                    count++;
                                }
                            }
                            notification = new Notification(this, id, package_name, app_name, title, flags, key, text, icon, actions_string);

                            notification_posted(notification);
                        }
                    }
                    break;
                case "notificationRemoved":
                    foreach (var i in eventItems) {
                        var object = i.get_object();
                        var id = object.get_int_member("id").to_string();
                        var package_name = object.get_string_member("packageName");
                        notification_removed(id, package_name);
                    }
                    break;
                case "listNotifications":
                    break;
                case "sms":
                    foreach (var i in eventItems) {
                        var object = i.get_object();
                        string? id = null;
                        string? sender = null;
                        string? sender_num = null;
                        string? msg = null;
                        BytesIcon? icon = null;

                        if (object.has_member("id")) {
                            id = object.get_string_member("id");
                        }

                        if (object.has_member("sender")) {
                            sender = object.get_string_member("sender");
                        }

                        if (object.has_member("sender_num")) {
                            sender_num = object.get_string_member("sender_num");
                        }

                        if (object.has_member("message")) {
                            msg = object.get_string_member("message");
                        }

                        if (object.has_member("icon")) {
                            icon = new BytesIcon(new Bytes(Base64.decode(object.get_string_member("icon"))));
                        }
                        SmsNotification notification = new SmsNotification(this, id, sender, sender_num, msg, icon);
                        sms_received(notification);
                    }
                    break;
                default:
                    warning("Unknown event: %s", event);
                    break;
                }
                /* read the next message */
                read_message();
            } catch (IOError e) {
                warning("There was a problem reading the notification: %s",
                        e.message);
                connected = false;
            }
        });
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/main.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

Application app = null;

bool on_terminate_app() {
    app.release();
    return false;
}

public static int main(string[] args) {
    Intl.bindtextdomain(Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
    Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "UTF-8");
    Intl.textdomain(Config.GETTEXT_PACKAGE);

    app = new Nuntius.Application();

    Unix.signal_add(Posix.Signal.INT, on_terminate_app);
    Unix.signal_add(Posix.Signal.HUP, on_terminate_app);
    Unix.signal_add(Posix.Signal.TERM, on_terminate_app);

    return app.run(args);
}

/* ex:set ts=4 et: */


================================================
FILE: src/notification.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class Notification : Object {
    public string id { get; construct set; }
    public string package_name { get; construct set; }
    public string app_name { get; construct set; }
    public string title { get; construct set; }
    public string body { get; construct set; }
    public string? flag { get; construct set; }
    public string? key { get; construct set; }
    public BytesIcon icon { get; construct set; }
    public string[]? actions { get; construct set; }
    public Connection connection { get; construct set; }

    private bool _read = false;

    [CCode (notify = false)]
    public bool read {
        get {
            return _read;
        }
        set {
            if (_read != value) {
                _read = value;
                notify_property("read");
            }
        }
    }

    public Notification(Connection connection, string id, string package_name, string app_name, string title, string? flag, string? key, string? body, BytesIcon? icon, string[]? actions) {
        Object(connection: connection, id: id, package_name: package_name, app_name: app_name, title: title, flag: flag, key: key, body: body, icon: icon, actions: actions);
    }

    public void send_dismiss_message() {
        Json.Builder builder = new Json.Builder();
        builder.begin_object();
        builder.set_member_name("event");
        builder.add_string_value("dismiss");
        builder.set_member_name("notification");
        builder.begin_object();

        if (key != null){
            builder.set_member_name("key");
            builder.add_string_value(_key);
        } else {
            builder.set_member_name("packageName");
            builder.add_string_value(_package_name);
            builder.set_member_name("flag");
            builder.add_string_value(_flag);
            builder.set_member_name("id");
            builder.add_string_value(_id);
        }
        builder.end_object();
        builder.end_object();

        Json.Generator generator = new Json.Generator();
        Json.Node root = builder.get_root();
        generator.set_root(root);
        string dismiss_message = generator.to_data(null);
        connection.send_message(dismiss_message);
    }

    public void send_action_message(string s) {
        Json.Builder builder = new Json.Builder();
        builder.begin_object();
        builder.set_member_name("event");
        builder.add_string_value("action");
        builder.set_member_name("action");
        builder.begin_object();

        builder.set_member_name("key");
        builder.add_string_value(_key);
        builder.set_member_name("actionName");
        builder.add_string_value(s);

        builder.end_object();
        builder.end_object();

        Json.Generator generator = new Json.Generator();
        Json.Node root = builder.get_root();
        generator.set_root(root);
        string action_message = generator.to_data(null);
        connection.send_message(action_message);
    }

    public GLib.Notification to_gnotification() {
        GLib.Notification notification = new GLib.Notification(title);

        if (body != null) {
            notification.set_body(body);
        }

        if (icon != null) {
            notification.set_icon(icon);
        }

        var variant = new Variant("(ss)", id, package_name);
        notification.set_default_action_and_target_value("app.open-notifications-view", variant);

        return notification;
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/notificationapp.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class NotificationApp : Object {
    public string id { get; construct set; }
    public Connection connection { get; construct set; }
    private string _app_name;
    private BytesIcon _icon;
    private uint _unread_notifications;
    private List<Notification> _notifications;

    public string app_name {
        get { return _app_name; }
    }

    public BytesIcon icon {
        get { return _icon; }
    }

    public uint unread_notifications {
        get { return _unread_notifications; }
    }

    public List<Notification> notifications {
        get { return _notifications; }
    }

    public NotificationApp(string id, Connection connection) {
        Object(id: id, connection: connection);
    }

    construct {
        _notifications = new List<Notification>();
    }

    public void add_notification(Notification notification) {
        _notifications.prepend(notification);

        // Update the icon with the latest notification
        if (_icon != notification.icon) {
            _icon = notification.icon;
            notify_property("icon");
        }

        if (_app_name != notification.app_name) {
            _app_name = notification.app_name;
            notify_property("app-name");
        }

        if (!notification.read) {
            _unread_notifications++;
            notify_property("unread-notifications");
        }

        notification.notify["read"].connect(() => {
            if (notification.read) {
                _unread_notifications--;
            } else {
                _unread_notifications++;
            }

            notify_property("unread-notifications");
        });
    }

    public Notification get_notification(string id) {
        Notification? n = null;

        foreach (var notif in _notifications) {
            if (notif.id == id) {
                n = notif;
                break;
            }
        }

        return n;
    }

    public void blacklist() {
        Json.Builder builder = new Json.Builder();
        builder.begin_object();
        builder.set_member_name("event");
        builder.add_string_value("blacklist");
        builder.set_member_name("app");
        builder.begin_object();

        builder.set_member_name("packageName");
        builder.add_string_value(id);

        builder.end_object();
        builder.end_object();

        Json.Generator generator = new Json.Generator();
        Json.Node root = builder.get_root();
        generator.set_root(root);

        string blacklist_message = generator.to_data(null);
        connection.send_message(blacklist_message);
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/notificationcounter.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

[GtkTemplate (ui = "/org/holylobster/nuntius/ui/notificationcounter.ui")]
public class NotificationCounter : Gtk.Frame {
    private uint _counter;

    [GtkChild]
    private Gtk.Label label_counter;

    public uint counter {
        get { return _counter; }
        set {
            _counter = value;
            label_counter.set_label(_counter.to_string());
        }
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/notificationsview.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class NotificationsView : Gtk.TextView {
    private Gtk.TextTag notification_tag;
    private Gtk.TextTag title_tag;
    private bool first_notification;

    construct {
        var buf = get_buffer();

        notification_tag = buf.create_tag("notification", null);
        title_tag = buf.create_tag("title",
                                   "weight",
                                   Pango.Weight.BOLD,
                                   null);
    }

    protected override void draw_layer(Gtk.TextViewLayer layer, Cairo.Context cr) {
        cr.save();

        if (layer == Gtk.TextViewLayer.BELOW) {
            if (get_buffer() == null) {
                return;
            }

            var context = get_style_context();

            context.save();
            context.add_class("notification");

            Gdk.Rectangle visible_rect;
            get_visible_rect(out visible_rect);

            Gdk.Rectangle clip;
            Gdk.cairo_get_clip_rectangle(cr, out clip);

            int x1, y1, x2, y2;
            x1 = clip.x;
            y1 = clip.y;
            x2 = x1 + clip.width;
            y2 = y1 + clip.height;

            window_to_buffer_coords(Gtk.TextWindowType.TEXT,
                                    x1, y1,
                                    out x1, out y1);

            window_to_buffer_coords(Gtk.TextWindowType.TEXT,
                                    x2, y2,
                                    out x2, out y2);

            Gtk.TextIter s, e;
            get_iter_at_location(out s, x1, y1);
            get_iter_at_location(out e, x2, y2);

            while (true) {
                Gtk.TextIter it = s;

                if (s.has_tag(notification_tag)) {
                    if (!it.forward_to_tag_toggle(notification_tag)) {
                        break;
                    }

                    Gdk.Rectangle rect1;
                    get_iter_location(s, out rect1);

                    buffer_to_window_coords(Gtk.TextWindowType.TEXT,
                                            rect1.x, rect1.y,
                                            out x1, out y1);

                    if (it.compare(e) > 0) {
                        it = e;
                    }

                    Gdk.Rectangle rect2;
                    get_iter_location(it, out rect2);
                    buffer_to_window_coords(Gtk.TextWindowType.TEXT,
                                            rect2.x + rect2.width, rect2.y + rect2.height,
                                            out x2, out y2);

                    int x = left_margin / 2;
                    int y = int.max(y1 - rect1.height / 2, clip.y);
                    int width = clip.width - left_margin / 2 - right_margin / 2;
                    int height = int.min(y2 + rect2.height / 2 - y1 + rect1.height / 2, clip.height);

                    context.render_background(cr, x, y, width, height);
                }

                if (!s.forward_to_tag_toggle(notification_tag)) {
                    break;
                }

                if (s.compare(e) > 0) {
                    break;
                }
            }

            context.restore();
        }

        cr.restore();
    }

    public void reset() {
        get_buffer().set_text("");
        first_notification = true;
    }

    public void add_notification(Notification notification) {
        var buf = get_buffer();
        var insert = buf.get_insert();
        Gtk.TextIter it;
        buf.get_iter_at_mark(out it, insert);

        if (first_notification) {
            buf.insert(ref it, "\n\n", -1);
        }

#if VALA_0_28
        buf.insert_with_tags(ref it, notification.title, -1, notification_tag, title_tag, null);

        if (notification.body != null) {
            buf.insert_with_tags(ref it, "\n\n", -1, notification_tag, null);
            buf.insert_with_tags(ref it, notification.body, -1, notification_tag, null);
        }
#else
        buf.insert_with_tags(it, notification.title, -1, notification_tag, title_tag, null);

        if (notification.body != null) {
            buf.insert_with_tags(it, "\n\n", -1, notification_tag, null);
            buf.insert_with_tags(it, notification.body, -1, notification_tag, null);
        }
#endif

        buf.insert(ref it, "\n\n\n", -1);

        first_notification = false;
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/qrencode.vapi
================================================

/*
 * Minimal VAPI file for LIBQRENCODE Barcode library.
 */
namespace Qrencode {

    [CCode (cheader_filename = "qrencode.h", cname = "QRcode", unref_function = "QRcode_free")]
    public class QRcode {
        [CCode (cname = "QRcode_encodeString")]
        public QRcode.encodeString(string digits, int version, EcLevel level, Mode hint, int casesensitive);

        public int version;
        public int width;
        [CCode (array_length = false)]
        public uint8[] data;
    }

    [CCode (cheader_filename = "qrencode.h", cname="QRencLevel")]
    public enum EcLevel {
        [CCode (cname="QR_ECLEVEL_L")]
        L,
        [CCode (cname="QR_ECLEVEL_M")]
        M,
        [CCode (cname="QR_ECLEVEL_Q")]
        Q,
        [CCode (cname="QR_ECLEVEL_H")]
        H
    }

    [CCode (cheader_filename = "qrencode.h", cname="QRencodeMode")]
    public enum Mode {
        [CCode (cname="QR_MODE_NUL")]
        NUL,
        [CCode (cname="QR_MODE_NUM")]
        NUM,
        [CCode (cname="QR_MODE_AN")]
        AN,
        [CCode (cname="QR_MODE_8")]
        B8,
        [CCode (cname="QR_MODE_KANJI")]
        KANJI,
        [CCode (cname="QR_MODE_STRUCTURE")]
        STRUCTURE
    }
}


================================================
FILE: src/qrimage.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

public class QRImage : Gtk.DrawingArea {
    private string _text;
    private Qrencode.QRcode? qrcode;
    private const double MIN_SQUARE_SIZE = 1.0;

    [CCode (notify = false)]
    public string text {
        get { return _text; }
        set {
            if (_text != value) {
                _text = value;
                qrcode = new Qrencode.QRcode.encodeString(_text, 0,
                                                          Qrencode.EcLevel.M,
                                                          Qrencode.Mode.B8, 1);
                notify_property("text");

                queue_draw();
            }
        }
    }

    protected override bool draw(Cairo.Context cr) {
        if (qrcode != null) {
            uint width, height;

            width = get_allocated_width();
            height = get_allocated_height();

            /* make it square */
            if (height < width) {
                width = height;
            }

            double square_size = width / qrcode.width;
            if (square_size < MIN_SQUARE_SIZE) {
                square_size = MIN_SQUARE_SIZE;
            }

            cr.save();

            cr.set_source_rgb(0, 0, 0);

            for (int iy = 0; iy < qrcode.width; iy++) {
                for (int ix = 0; ix < qrcode.width; ix++) {
                    /* Symbol data is represented as an array contains
                     * width*width uchars. Each uchar represents a module
                     * (dot). If the less significant bit of the uchar
                     * is 1, the corresponding module is black. The other
                     * bits are meaningless for us.
                     */
                    if ((qrcode.data[iy * qrcode.width + ix] & 1) != 0) {
                        cr.rectangle(ix * square_size, iy * square_size, square_size, square_size);
                        cr.fill();
                    }
                }
            }

            cr.restore();
        }

        return false;
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: src/resources/css/nuntius-style.css
================================================
.nuntius-titlebar-left {
    /* the horizontal padding confuses left_side_size_group, so we
       add it as margin-left to the first button instead (in mainWindow.ui);
       also set the vertical padding to 0 so the separator extends to the
       bottom */
    padding: 0 1px;
}

.nuntius-titlebar-left:dir(ltr),
.nuntius-titlebar-right:dir(rtl) {
    border-top-right-radius: 0;
}

.nuntius-titlebar-right:dir(ltr),
.nuntius-titlebar-left:dir(rtl) {
    border-top-left-radius: 0;
}

.nuntius-titlebar-separator {
    border-image: linear-gradient(to bottom, @theme_bg_color, shade(@borders, 1.2));
    border-image-width: 0 1px 0 0;
    border-image-slice: 1;
}

.nuntius-titlebar-separator:backdrop {
    border-image: none;
    border-color: transparent;
}

NuntiusAppsListPanel.frame:dir(ltr) {
  border-width: 0 1px 0 0;
}

NuntiusAppsListPanel.frame:dir(rtl) {
  border-width: 0 0 0 1px;
}

.apps-list-view {
  background-color: transparent;
}

NuntiusNotificationCounter {
  border-style: none;
  border-radius: 10px;
  background-color: darker(@theme_selected_bg_color);
  color: @theme_selected_fg_color;
  padding: 1px 6px;
}

/* Primary toolbar with no line at top to avoid conflicts with frame border */
NuntiusWindow .primary-toolbar.toolbar {
  border-width: 0;
  border-bottom-width: 1px;
  border-style: solid;
  border-color: @borders;
}

NuntiusNotificationsView .notification {
  border-radius: 2px;
  background-color: @theme_bg_color;
}


================================================
FILE: src/resources/gtk/menus.ui
================================================
<?xml version="1.0"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <menu id="app-menu">
    <section>
      <item>
        <attribute name="label" translatable="yes">Show _QR Code</attribute>
        <attribute name="action">app.show-qrcode</attribute>
      </item>
      <item>
        <attribute name="label" translatable="yes">_About</attribute>
        <attribute name="action">app.about</attribute>
      </item>
    </section>
  </menu>
</interface>


================================================
FILE: src/resources/nuntius.gresource.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/org/holylobster/nuntius">
    <file preprocess="xml-stripblanks">ui/window.ui</file>
    <file preprocess="xml-stripblanks">ui/appslistpanel.ui</file>
    <file preprocess="xml-stripblanks">ui/approw.ui</file>
    <file preprocess="xml-stripblanks">ui/notificationcounter.ui</file>
    <file preprocess="xml-stripblanks">gtk/menus.ui</file>
    <file>css/nuntius-style.css</file>
  </gresource>
</gresources>


================================================
FILE: src/resources/ui/approw.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
  <requires lib="gtk+" version="3.12"/>
  <template class="NuntiusAppsListAppRow" parent="GtkListBoxRow">
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <child>
      <object class="GtkGrid" id="grid1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="margin">6</property>
        <property name="column_spacing">10</property>
        <child>
          <object class="GtkImage" id="image">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="halign">center</property>
            <property name="valign">center</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel" id="label">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="halign">start</property>
            <property name="valign">center</property>
            <property name="hexpand">true</property>
            <property name="ellipsize">end</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
        <child>
          <object class="NuntiusNotificationCounter" id="notification_counter">
            <property name="visible">False</property>
            <property name="can_focus">False</property>
            <property name="halign">end</property>
            <property name="valign">center</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
      </object>
    </child>
  </template>
</interface>


================================================
FILE: src/resources/ui/appslistpanel.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
  <requires lib="gtk+" version="3.14"/>
  <template class="NuntiusAppsListPanel" parent="GtkFrame">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="label_xalign">0</property>
    <property name="shadow_type">in</property>
    <child>
      <object class="GtkGrid" id="grid1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkToolbar" id="toolbar">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <child>
              <object class="GtkToolItem" id="search_tool_item">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <child>
                  <object class="GtkSearchEntry" id="filter_entry">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="width-chars">30</property>
                    <property name="placeholder_text" translatable="yes">Type to search</property>
                    <signal name="changed" handler="filter_entry_changed" after="no" swapped="no"/>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="homogeneous">True</property>
              </packing>
            </child>
            <style>
              <class name="primary-toolbar"/>
            </style>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkScrolledWindow" id="scrolledwindow">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="hscrollbar_policy">never</property>
            <child>
              <object class="NuntiusAppsList" id="apps_list_view">
                <property name="visible">True</property>
                <property name="selection_mode">browse</property>
                <style>
                  <class name="apps-list-view"/>
                </style>
              </object>
            </child>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
          </packing>
        </child>
      </object>
    </child>
  </template>
</interface>


================================================
FILE: src/resources/ui/notificationcounter.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
  <template class="NuntiusNotificationCounter" parent="GtkFrame">
    <property name="can_focus">False</property>
    <property name="shadow_type">none</property>
    <child>
      <object class="GtkLabel" id="label_counter">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="halign">center</property>
        <property name="valign">center</property>
        <property name="ellipsize">end</property>
      </object>
    </child>
  </template>
</interface>


================================================
FILE: src/resources/ui/window.ui
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
  <requires lib="gtk+" version="3.12"/>
  <template class="NuntiusWindow" parent="GtkApplicationWindow">
    <property name="can_focus">False</property>
    <property name="default_width">800</property>
    <property name="default_height">600</property>
    <property name="title" translatable="yes">Nuntius</property>
    <property name="icon_name">nuntius</property>
    <child type="titlebar">
      <object class="GtkBox" id="box_titlebar">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkHeaderBar" id="titlebar_left">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">False</property>
            <property name="title" translatable="yes">All Applications</property>
            <child>
              <object class="GtkLabel" id="titlebar_separator">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <style>
                  <class name="nuntius-titlebar-separator"/>
                </style>
              </object>
              <packing>
                <property name="pack_type">end</property>
              </packing>
            </child>
            <style>
              <class name="nuntius-titlebar-left"/>
              <class name="titlebar"/>
            </style>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkHeaderBar" id="titlebar_right">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <property name="show_close_button">True</property>
            <style>
              <class name="nuntius-titlebar-right"/>
              <class name="titlebar"/>
            </style>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
    </child>
    <child>
      <object class="GtkGrid" id="main_grid">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkFrame" id="sidebar_frame">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">False</property>
            <property name="vexpand">True</property>
            <property name="label_xalign">0</property>
            <property name="shadow_type">none</property>
            <child>
              <object class="NuntiusAppsListPanel" id="apps_list_panel">
                <property name="visible">True</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkScrolledWindow" id="view_scrolled">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <child>
              <object class="NuntiusNotificationsView" id="notifications_view">
                <property name="visible">True</property>
                <property name="editable">False</property>
                <property name="cursor_visible">False</property>
                <property name="wrap_mode">word</property>
                <property name="left_margin">40</property>
                <property name="right_margin">40</property>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </template>
  <object class="GtkSizeGroup" id="left_side_size_group">
    <property name="mode">horizontal</property>
    <widgets>
      <widget name="titlebar_left"/>
      <widget name="sidebar_frame"/>
    </widgets>
  </object>
</interface>


================================================
FILE: src/smsnotification.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */
namespace Nuntius {

public class SmsNotification : Object {
    public string id { get; construct set; }
    public string sender { get; construct set; }
    public string sender_num { get; construct set; }
    public string message { get; construct set; }
    public BytesIcon icon { get; construct set; }
    public Connection connection { get; construct set; }

    public SmsNotification(Connection connection, string id, string sender, string sender_num, string message, BytesIcon icon) {
        Object(connection: connection, id: id, sender: sender, sender_num: sender_num, message: message, icon: icon);
    }

    public void send_sms_message(string message) {
        Json.Builder builder = new Json.Builder();
        builder.begin_object();
        builder.set_member_name("event");
        builder.add_string_value("sms");
        builder.set_member_name("sms");
        builder.begin_object();

        builder.set_member_name("senderNum");
        builder.add_string_value(_sender_num);

        builder.set_member_name("msg");
        builder.add_string_value(message);

        builder.end_object();
        builder.end_object();

        Json.Generator generator = new Json.Generator();
        Json.Node root = builder.get_root();
        generator.set_root(root);
        string sms_message = generator.to_data(null);
        connection.send_message(sms_message);
    }

    public GLib.Notification to_gnotification() {
        GLib.Notification notification = new GLib.Notification(sender);

        notification.set_body(message);
        notification.set_icon(icon);

        // FIXME: just a test message until we have UI to type the reply
        var variant = new Variant("(ss)", id, "Sent by Nuntius");
        notification.add_button_with_target_value(_("Reply"),"app.send-sms", variant);

        return notification;
    }
}

}


================================================
FILE: src/testview.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

/* Just a temporary UI to send actions, this should go in the main UI */
public class TestView : Gtk.Window {

    Notification notification;

    public TestView(Notification notification) {
        this.notification = notification;

        // Sets the title of the Window:
        this.title = notification.title;

        // Center window at startup:
        this.window_position = Gtk.WindowPosition.CENTER;

        // Sets the default size of a window:
        this.set_default_size(500,150);

        // Whether the titlebar should be hidden during maximization.
        this.hide_titlebar_when_maximized = false;

        // Method called on pressing [X]
        this.destroy.connect(() => {
            stdout.printf("Bye!\n");
        });

        Gtk.Box vertical_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
        vertical_box.set_margin_left(20);
        vertical_box.set_margin_right(20);
        this.add(vertical_box);

        Gtk.Box notification_area = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 10);
        vertical_box.pack_start(notification_area);

        Gtk.Image icon = new Gtk.Image();
        icon.set_from_gicon(notification.icon, Gtk.IconSize.DIALOG);
        notification_area.pack_start(icon);

        var label = new Gtk.Label(notification.body);
        notification_area.pack_start(label);

        Gtk.Box button_area = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 10);
        vertical_box.pack_start(button_area, false, false, 10);
        var dismiss_button = new Gtk.Button.with_label("Dismiss");

        dismiss_button.clicked.connect(() => {
            notification.send_dismiss_message();
        });

        button_area.pack_start(dismiss_button);

        if (notification.actions != null) {
            var actions = notification.actions;
            foreach(string s in actions) {
                var action_button = new Gtk.Button.with_label(s);
                button_area.pack_start(action_button);
                action_button.clicked.connect(() => {
                    notification.send_action_message(s);
                });
            }
        }

        var blacklist_button = new Gtk.Button.with_label("Blacklist this app");

        blacklist_button.clicked.connect(() => {
            var app = (Application) GLib.Application.get_default();
            app.blacklist_application(notification.package_name);
        });

        button_area.pack_start(blacklist_button);
    }
}

}


================================================
FILE: src/window.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

namespace Nuntius {

[GtkTemplate (ui = "/org/holylobster/nuntius/ui/window.ui")]
public class Window : Gtk.ApplicationWindow {
    [GtkChild]
    private AppsListPanel apps_list_panel;
    [GtkChild]
    private NotificationsView notifications_view;
    [GtkChild]
    private Gtk.HeaderBar titlebar_right;

    private GLib.Settings settings;

    public Window(Application app) {
        Object(application: app);
    }

    construct {
        settings = new Settings("org.holylobster.nuntius.state.window");
        settings.delay ();

        destroy.connect(() => {
            settings.apply();
        });

        // Setup window geometry saving
        Gdk.WindowState window_state = (Gdk.WindowState)settings.get_int("state");
        if (Gdk.WindowState.MAXIMIZED in window_state) {
            maximize();
        }

        int width, height;
        settings.get ("size", "(ii)", out width, out height);
        resize(width, height);

        apps_list_panel.selection_changed.connect(on_selection_changed);
    }

    protected override bool configure_event(Gdk.EventConfigure event) {
        if (get_realized() && !(Gdk.WindowState.MAXIMIZED in get_window ().get_state())) {
            settings.set("size", "(ii)", event.width, event.height);
        }

        return base.configure_event(event);
    }

    protected override bool window_state_event(Gdk.EventWindowState event) {
        settings.set_int("state", event.new_window_state);
        return base.window_state_event(event);
    }

    protected override bool delete_event(Gdk.EventAny event) {
        return base.hide_on_delete();
    }

    private void on_selection_changed(NotificationApp? notification_app) {
        if (notification_app == null) {
            titlebar_right.title = null;
            return;
        }

        titlebar_right.title = notification_app.app_name;

        notifications_view.reset();

        foreach (var n in notification_app.notifications) {
            notifications_view.add_notification(n);

            if (!n.read) {
                this.application.withdraw_notification(n.id);
                n.read = true;
            }
        }
    }
}

} // namespace Nuntius

/* ex:set ts=4 et: */


================================================
FILE: tests/qrtest.vala
================================================
/*
 * Copyright (C) 2015 - Holy Lobster
 *
 * Nuntius is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Nuntius 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Nuntius. If not, see <http://www.gnu.org/licenses/>.
 */

public static int main(string[] args) {
    Gtk.init(ref args);

    var window = new Gtk.Window();
    window.title = "QR Test";
    window.border_width = 10;
    window.set_default_size(350, 70);
    window.destroy.connect(Gtk.main_quit);

    var qr = new Nuntius.QRImage();
    qr.text = "This is a test";

    window.add(qr);
    window.show_all();

    Gtk.main();

    return 0;
}

/* ex:set ts=4 et: */
Download .txt
gitextract_9d2x1sfm/

├── .tx/
│   └── config
├── AUTHORS
├── COPYING
├── Makefile.am
├── NEWS
├── README.md
├── autogen.sh
├── configure.ac
├── createcert.sh
├── data/
│   ├── icons/
│   │   └── render-bitmaps.rb
│   ├── org.holylobster.nuntius.appdata.xml.in
│   ├── org.holylobster.nuntius.desktop.in
│   ├── org.holylobster.nuntius.gschema.xml.in
│   └── org.holylobster.nuntius.service.in
├── git.mk
├── po/
│   ├── LINGUAS
│   ├── POTFILES.in
│   ├── POTFILES.skip
│   ├── de.po
│   ├── es.po
│   ├── pl.po
│   └── sk.po
├── src/
│   ├── application.vala
│   ├── appslist.vala
│   ├── appslistpanel.vala
│   ├── config.vapi
│   ├── connection.vala
│   ├── main.vala
│   ├── notification.vala
│   ├── notificationapp.vala
│   ├── notificationcounter.vala
│   ├── notificationsview.vala
│   ├── qrencode.vapi
│   ├── qrimage.vala
│   ├── resources/
│   │   ├── css/
│   │   │   └── nuntius-style.css
│   │   ├── gtk/
│   │   │   └── menus.ui
│   │   ├── nuntius.gresource.xml
│   │   └── ui/
│   │       ├── approw.ui
│   │       ├── appslistpanel.ui
│   │       ├── notificationcounter.ui
│   │       └── window.ui
│   ├── smsnotification.vala
│   ├── testview.vala
│   └── window.vala
└── tests/
    └── qrtest.vala
Download .txt
SYMBOL INDEX (1 symbols across 1 files)

FILE: data/icons/render-bitmaps.rb
  function renderit (line 9) | def renderit(file,explicit)
Condensed preview — 45 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (142K chars).
[
  {
    "path": ".tx/config",
    "chars": 147,
    "preview": "[main]\nhost = https://www.transifex.com\ntype = PO\n\n[nuntius-linux.strings]\nfile_filter = po/<lang>.po\nsource_file = po/n"
  },
  {
    "path": "AUTHORS",
    "chars": 126,
    "preview": "Andrea Curtoni <andreacurtoni@gmail.com>\nIgnacio Casal Quinteiro <nacho.resa@gmail.com>\nPaolo Borelli <pborelli@katamail"
  },
  {
    "path": "COPYING",
    "chars": 18093,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Fr"
  },
  {
    "path": "Makefile.am",
    "chars": 4315,
    "preview": "ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}\n\nSUBDIRS = po\n\n# desktop file\ndesktopdir = $(datadir)/applications\ndesktop_in_f"
  },
  {
    "path": "NEWS",
    "chars": 424,
    "preview": "=============\nnuntius 0.2.0\n=============\n\nNew Features and Fixes\n======================\n- Added user interface\n- Added "
  },
  {
    "path": "README.md",
    "chars": 1958,
    "preview": "Nuntius\n===================================\n\n## Introduction\nNuntius delivers notifications from your phone or tablet to"
  },
  {
    "path": "autogen.sh",
    "chars": 665,
    "preview": "#!/bin/sh\n# Run this to generate all the initial makefiles, etc.\n\ntest -n \"$srcdir\" || srcdir=`dirname \"$0\"`\ntest -n \"$s"
  },
  {
    "path": "configure.ac",
    "chars": 1320,
    "preview": "AC_PREREQ(2.63)\n\nAC_INIT([nuntius], [0.2.0])\n\ndnl http://people.gnome.org/~walters/docs/build-api.txt\ndnl We don't suppo"
  },
  {
    "path": "createcert.sh",
    "chars": 914,
    "preview": "#!/bin/bash\n\nfunction try {\n    \"$@\"\n    local status=$?\n    if [ $status -ne 0 ]; then\n        echo -e \"\\nError with $1"
  },
  {
    "path": "data/icons/render-bitmaps.rb",
    "chars": 2132,
    "preview": "#!/usr/bin/env ruby\n\nrequire \"rexml/document\"\nrequire \"fileutils\"\ninclude REXML\nINKSCAPE = '/usr/bin/inkscape'\nSRC = \"./"
  },
  {
    "path": "data/org.holylobster.nuntius.appdata.xml.in",
    "chars": 865,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Copyright 2015 Ignacio Casal Quinteiro <icq@gnome.org> -->\n<application>\n  <"
  },
  {
    "path": "data/org.holylobster.nuntius.desktop.in",
    "chars": 378,
    "preview": "[Desktop Entry]\nName=Nuntius\nGenericName=Nuntius\nX-GNOME-FullName=Nuntius\n_Comment=Deliver notifications from your phone"
  },
  {
    "path": "data/org.holylobster.nuntius.gschema.xml.in",
    "chars": 748,
    "preview": "<schemalist gettext-domain=\"@GETTEXT_PACKAGE@\">\n  <schema id=\"org.holylobster.nuntius.state\" path=\"/org/holylobster/nunt"
  },
  {
    "path": "data/org.holylobster.nuntius.service.in",
    "chars": 90,
    "preview": "[D-BUS Service]\nName=org.holylobster.nuntius\nExec=@bindir@/nuntius --gapplication-service\n"
  },
  {
    "path": "git.mk",
    "chars": 10593,
    "preview": "# git.mk\n#\n# Copyright 2009, Red Hat, Inc.\n# Copyright 2010,2011,2012,2013 Behdad Esfahbod\n# Written by Behdad Esfahbod\n"
  },
  {
    "path": "po/LINGUAS",
    "chars": 81,
    "preview": "# nuntius translations\n# please keep this list sorted alphabetically\nde\nes\npl\nsk\n"
  },
  {
    "path": "po/POTFILES.in",
    "chars": 471,
    "preview": "# List of source files containing translatable strings.\n# Please keep this file sorted alphabetically.\ndata/org.holylobs"
  },
  {
    "path": "po/POTFILES.skip",
    "chars": 158,
    "preview": "# List of source files that should *not* be translated.\n# Please keep this file sorted alphabetically.\nsrc/application.c"
  },
  {
    "path": "po/de.po",
    "chars": 3171,
    "preview": "# SOME DESCRIPTIVE TITLE.\n# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n# This file is distributed under the same "
  },
  {
    "path": "po/es.po",
    "chars": 3161,
    "preview": "# SOME DESCRIPTIVE TITLE.\n# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n# This file is distributed under the same "
  },
  {
    "path": "po/pl.po",
    "chars": 3693,
    "preview": "# Polish translation for nuntius-linux.\n# Copyright © 2015-2016 the nuntius-linux authors.\n# This file is distributed un"
  },
  {
    "path": "po/sk.po",
    "chars": 3286,
    "preview": "# SOME DESCRIPTIVE TITLE.\n# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n# This file is distributed under the same "
  },
  {
    "path": "src/application.vala",
    "chars": 19537,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/appslist.vala",
    "chars": 5105,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/appslistpanel.vala",
    "chars": 1865,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/config.vapi",
    "chars": 282,
    "preview": "[CCode (cprefix = \"\", lower_case_cprefix = \"\", cheader_filename = \"config.h\")]\nnamespace Config {\n    public const strin"
  },
  {
    "path": "src/connection.vala",
    "chars": 8699,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/main.vala",
    "chars": 1256,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/notification.vala",
    "chars": 4215,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/notificationapp.vala",
    "chars": 3352,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/notificationcounter.vala",
    "chars": 1128,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/notificationsview.vala",
    "chars": 5097,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/qrencode.vapi",
    "chars": 1206,
    "preview": "\n/*\n * Minimal VAPI file for LIBQRENCODE Barcode library.\n */\nnamespace Qrencode {\n\n    [CCode (cheader_filename = \"qren"
  },
  {
    "path": "src/qrimage.vala",
    "chars": 2754,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/resources/css/nuntius-style.css",
    "chars": 1462,
    "preview": ".nuntius-titlebar-left {\n    /* the horizontal padding confuses left_side_size_group, so we\n       add it as margin-left"
  },
  {
    "path": "src/resources/gtk/menus.ui",
    "chars": 465,
    "preview": "<?xml version=\"1.0\"?>\n<interface>\n  <!-- interface-requires gtk+ 3.0 -->\n  <menu id=\"app-menu\">\n    <section>\n      <ite"
  },
  {
    "path": "src/resources/nuntius.gresource.xml",
    "chars": 483,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gresources>\n  <gresource prefix=\"/org/holylobster/nuntius\">\n    <file preprocess"
  },
  {
    "path": "src/resources/ui/approw.ui",
    "chars": 2128,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated with glade 3.18.3 -->\n<interface>\n  <requires lib=\"gtk+\" version=\""
  },
  {
    "path": "src/resources/ui/appslistpanel.ui",
    "chars": 2929,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated with glade 3.18.1 -->\n<interface>\n  <requires lib=\"gtk+\" version=\""
  },
  {
    "path": "src/resources/ui/notificationcounter.ui",
    "chars": 621,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated with glade 3.18.1 -->\n<interface>\n  <template class=\"NuntiusNotifi"
  },
  {
    "path": "src/resources/ui/window.ui",
    "chars": 4379,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated with glade 3.18.1 -->\n<interface>\n  <requires lib=\"gtk+\" version=\""
  },
  {
    "path": "src/smsnotification.vala",
    "chars": 2537,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/testview.vala",
    "chars": 3146,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "src/window.vala",
    "chars": 2897,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  },
  {
    "path": "tests/qrtest.vala",
    "chars": 1089,
    "preview": "/*\n * Copyright (C) 2015 - Holy Lobster\n *\n * Nuntius is free software; you can redistribute it and/or modify\n * it unde"
  }
]

About this extraction

This page contains the full source code of the holylobster/nuntius-linux GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 45 files (130.3 KB), approximately 32.8k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!