I have made the following changes intended for :
  CE:MW:Shared / timed

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.pub.meego.com//request/show/7551

Thank You,
pgerdt

[This message was auto-generated]

---

Request # 7551:

Messages from BOSS:

State: review at 2012-12-17T11:49:38 by bossbot

Reviews:
       accepted by bossbot : Prechecks succeeded.
       new for CE-maintainers : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:pgerdt:branches:CE:MW:Shared / timed -> CE:MW:Shared / timed
  
changes files:
--------------
--- timed.changes
+++ timed.changes
@@ -0,0 +1,6 @@
+* Wed Dec 13 2012 Petri M. Gerdt <[email protected]> - 2.55
+- Tarball from new source location: https://github.com/nemomobile/timed
+- Removed patches from OBS, patches have been applied to git repository
+- Enabled building of DSME interface
+- Moved systemd service file and dbus conf file to git
+

old:
----
  lower-server-loglevel.patch
  meego-middleware-timed-2.54.tar.gz
  timed-2.11-run-as-system-service.patch
  timed-2.27-debugflag-fix.patch
  timed-2.27-typofix.patch
  timed-2.37-cellular-separation.patch
  timed-2.37-uid-creds.patch
  timed-2.53-BMC17566-update-old-date-on-first-boot.patch
  timed-2.53-disable-dsme.patch
  timed-2.53-no-docs.patch
  timed-2.53-no-werror.patch
  timed-2.54-add-missing-libs-for-linking.patch
  timed.conf
  timed.service

new:
----
  meego-middleware-timed-2.55.tar.gz

spec files:
-----------
--- timed.spec
+++ timed.spec
@@ -9,26 +9,13 @@
 # << macros
 
 Summary:    Time daemon
-Version:    2.54
+Version:    2.55
 Release:    1
 Group:      System/System Control
 License:    LGPLv2
-URL:        http://meego.gitorious.org/meego-middleware/timed
+URL:        https://github.com/nemomobile/timed
 Source0:    meego-middleware-%{name}-%{version}.tar.gz
-Source1:    %{name}.conf
-Source2:    %{name}.service
 Source100:  timed.yaml
-Patch0:     %{name}-2.11-run-as-system-service.patch
-Patch1:     %{name}-2.27-debugflag-fix.patch
-Patch2:     %{name}-2.27-typofix.patch
-Patch3:     %{name}-2.37-cellular-separation.patch
-Patch4:     %{name}-2.37-uid-creds.patch
-Patch5:     %{name}-2.53-BMC17566-update-old-date-on-first-boot.patch
-Patch6:     %{name}-2.53-no-werror.patch
-Patch7:     lower-server-loglevel.patch
-Patch8:     %{name}-2.53-no-docs.patch
-Patch9:     timed-2.53-disable-dsme.patch
-Patch10:     timed-2.54-add-missing-libs-for-linking.patch
 Requires:   tzdata
 Requires:   tzdata-timed
 Requires:   systemd
@@ -40,6 +27,7 @@
 BuildRequires:  pkgconfig(contextprovider-1.0)
 BuildRequires:  pkgconfig(libpcrecpp)
 BuildRequires:  pkgconfig(QtCore) >= 4.7
+BuildRequires:  pkgconfig(dsme_dbus_if)
 BuildRequires:  libiodata-devel >= 0.17
 BuildRequires:  libqmlog-devel >= 0.10
 BuildRequires:  libxslt
@@ -84,28 +72,6 @@
 %prep
 %setup -q -n meego-middleware-%{name}
 
-# %{name}-2.11-run-as-system-service.patch
-%patch0 -p1
-# %{name}-2.27-debugflag-fix.patch
-%patch1 -p1
-# %{name}-2.27-typofix.patch
-%patch2 -p1
-# %{name}-2.37-cellular-separation.patch
-%patch3 -p1
-# %{name}-2.37-uid-creds.patch
-%patch4 -p1
-# %{name}-2.53-BMC17566-update-old-date-on-first-boot.patch
-%patch5 -p1
-# %{name}-2.53-no-werror.patch
-%patch6 -p1
-# lower-server-loglevel.patch
-%patch7 -p1
-# %{name}-2.53-no-docs.patch
-%patch8 -p1
-# timed-2.53-disable-dsme.patch
-%patch9 -p1
-# timed-2.54-add-missing-libs-for-linking.patch
-%patch10 -p1
 # >> setup
 # << setup
 
@@ -120,7 +86,7 @@
 # << build pre
 
 %qmake  \
-    -recursive "CONFIG += MEEGO"
+    -recursive "CONFIG += MEEGO dsme_dbus_if"
 
 make %{?jobs:-j%jobs}
 
@@ -140,10 +106,9 @@
 #install -m 644 -D src/doc/libtimed.3 %{buildroot}/%{_mandir}/man3/libtimed.3
 #install -m 644 src/doc/libtimed-voland.3 
%{buildroot}/%{_mandir}/man3/libtimed-voland.3
 
-install -m 644 -D %{SOURCE1} 
%{buildroot}/%{_sysconfdir}/dbus-1/system.d/%{name}.conf
 install -d %{buildroot}/%{_localstatedir}/cache/%{name}/aegis/
 
-install -m 644 -D %{SOURCE2} %{buildroot}/lib/systemd/system/%{name}.service
+# The file %{buildroot}/lib/systemd/system/%{name}.service is installed by 
make install
 install -d %{buildroot}/lib/systemd/system/multi-user.target.wants/
 ln -s ../%{name}.service 
%{buildroot}/lib/systemd/system/multi-user.target.wants/%{name}.service
 

other changes:
--------------

++++++ meego-middleware-timed-2.54.tar.gz -> meego-middleware-timed-2.55.tar.gz
--- src/lib/interface.h
+++ src/lib/interface.h
@@ -105,10 +105,12 @@
       qtdbus_method(pid, (void)) ;
       qtdbus_method(parse, (const QString &text), text) ;
       qtdbus_method(customization_values, (void)) ;
+#if __HARMATTAN__
       qtdbus_method(fake_nitz_signal, (int mcc, int offset, int time, int 
dst), mcc, offset, time, dst) ;
       qtdbus_method(fake_operator_signal, (const QString &mcc, const QString 
&mnc), mcc, mnc) ;
       qtdbus_method(fake_csd_time_signal, (const QString &mcc, const QString 
&mnc, int offset, int time, int dst, int seconds, int nano_seconds), mcc, mnc, 
offset, time, dst, seconds, nano_seconds) ;
       qtdbus_method(fake_csd_time_signal_now, (const QString &mcc, const 
QString &mnc, int offset, int time, int dst), mcc, mnc, offset, time, dst) ;
+#endif // __HARMATTAN__
       qtdbus_method(get_log_level, (void)) ;
       qtdbus_method(set_log_level, (int n), n) ;
     } ;
--- src/lib/lib.pro
+++ src/lib/lib.pro
@@ -44,4 +44,4 @@
   LIBS += -lsysinfo
   QMAKE_CXXFLAGS  += -Wall -Wno-psabi
 }
-QMAKE_CXXFLAGS  += -Wall -Werror
+QMAKE_CXXFLAGS  += -Wall
--- src/memory/memory.pro
+++ src/memory/memory.pro
@@ -4,7 +4,10 @@
 CONFIG += qmlog
 CONFIG += link_pkgconfig
 
-PKGCONFIG += contextprovider-1.0 libpcrecpp dsme_dbus_if
+PKGCONFIG += contextprovider-1.0 libpcrecpp
+CONFIG(dsme_dbus_if) {
+    PKGCONFIG += dsme_dbus_if
+}
 
 TEMPLATE = app
 TARGET = memory
--- src/root.pro
+++ src/root.pro
@@ -1,5 +1,5 @@
 TEMPLATE = subdirs
-SUBDIRS = lib voland doc server simple-client fake-dialog-ui ticker 
logging-test ntp tfd
+SUBDIRS = lib voland server simple-client fake-dialog-ui ticker logging-test 
ntp tfd
 SUBDIRS += memory
 # SUBDIRS += arch
 CONFIG += ordered
--- src/server/adaptor.h
+++ src/server/adaptor.h
@@ -246,6 +246,7 @@
     timed->halt(string_q_to_std(what)) ;
   }
 
+#if F_CSD
   bool fake_csd_time_signal(const QString &mcc, const QString &mnc, int 
offset, int time, int dst, int seconds, int nano_seconds)
   {
     log_notice("(fake_csd_time_signal) mcc='%s' mnc='%s' offset=%d time=%d 
dst=%d seconds=%d nano_seconds=%d", mcc.toStdString().c_str(), 
mnc.toStdString().c_str(), offset, time, dst, seconds, nano_seconds) ;
@@ -295,6 +296,7 @@
     timed->csd->process_csd_network_operator(mcc, mnc) ;
     return true ;
   }
+#endif // F_CSD
 
   int get_log_level(const QDBusMessage &message)
   {
--- src/server/aegis.cpp
+++ src/server/aegis.cpp
@@ -40,7 +40,7 @@
 #if F_CREDS_AEGIS_LIBCREDS
 credentials_t Aegis::credentials_from_creds_t(creds_t aegis_creds)
 {
-  credentials_t creds ; // uid/gid is set to nobody/nogroup by default
+  credentials_t creds ; // uid/gid is set to nobody/nobody by default
 
   // using a buffer directly on stack, if not enough -> use heap
   static const size_t buf_stack_len = 1024 ;
--- src/server/credentials.cpp
+++ src/server/credentials.cpp
@@ -24,12 +24,20 @@
 #include "f.h"
 
 #include <stdlib.h>
+#if F_CREDS_AEGIS_LIBCREDS
 #include <sys/creds.h>
+#endif // F_CREDS_AEGIS_LIBCREDS
 
 #include <QDBusReply>
 
 #include <qmlog>
 
+#if F_CREDS_UID
+#include <pwd.h>
+#include <grp.h>
+#include "timed/interface"
+#endif // F_CREDS_UID
+
 #include "credentials.h"
 
 #include "aegis.h"
@@ -84,6 +92,42 @@
 
 #endif // F_DBUS_INFO_AS_CREDENTIALS
 
+uid_t nameToUid(string name)
+{
+  passwd *info = getpwnam(name.c_str()) ;
+  if (info)
+    return info->pw_uid ;
+  // couldn't get uid for username
+  return -1 ;
+}
+
+string uidToName(uid_t u)
+{
+  passwd *info = getpwuid(u) ;
+  if (info)
+    return info->pw_name ;
+  // couldn't get name for uid
+  return "nobody" ;
+}
+
+gid_t nameToGid(string name)
+{
+  group *info = getgrnam(name.c_str()) ;
+  if (info)
+    return info->gr_gid ;
+  // couldn't get gid for groupname
+  return -1 ;
+}
+
+string gidToName(gid_t g)
+{
+  group *info = getgrgid(g) ;
+  if (info)
+    return info->gr_name ;
+  // couldn't get name for gid
+  return "nobody" ;
+}
+
 bool credentials_t::apply() const
 {
 #if F_CREDS_AEGIS_LIBCREDS
@@ -97,8 +141,15 @@
   creds_free(aegis_creds_want) ;
 
   return res ;
-#else // F_CREDS_AEGIS_LIBCREDS
-#error credentials_t::apply() is only implemented for F_CREDS_AEGIS_LIBCREDS
+#elif F_CREDS_UID
+  if (setgid(nameToGid(gid)) != 0 || setuid(nameToUid(uid)) != 0)
+  {
+    log_error("uid cred_set() failed") ;
+    return false ;
+  }
+  return true ;
+#else
+#error unimplemented credentials type
 #endif
 }
 
@@ -142,10 +193,14 @@
     os << "}" ;
 
   bool equal = id_matches and all_accrued and all_dropped ;
+  bool ret = id_matches and all_dropped ;
 
 #undef COMMA_A
 #undef COMMA_D
 
+#else
+  bool equal = id_matches ;
+  bool ret =  id_matches ;
 #endif // F_TOKENS_AS_CREDENTIALS
 
 #undef COMMA
@@ -153,7 +208,7 @@
   if(!equal)
     log_warning("applied and wanted credentials differ: %s", os.str().c_str()) 
;
 
-  return id_matches and all_dropped ;
+  return ret ;
 }
 
 credentials_t credentials_t::from_given_process(pid_t pid)
@@ -165,14 +220,23 @@
   creds_free(aegis_creds) ;
 
   return creds ;
-#else // not F_CREDS_AEGIS_LIBCREDS
-#error credentials_t::from_given_process(pid_t) is only implemented for 
F_CREDS_AEGIS_LIBCREDS
+#elif F_CREDS_UID
+// TODO: currently nobody:nobody is reported for all processes
+  return credentials_t() ;
+#else
+#error unimplemented credentials type
 #endif
 }
 
 credentials_t credentials_t::from_current_process()
 {
+#if F_CREDS_AEGIS_LIBCREDS
   return credentials_t::from_given_process(0) ;
+#elif F_CREDS_UID
+  return credentials_t(uidToName(getuid()), gidToName(getgid())) ;
+#else
+#error unimplemented credentials type
+#endif
 }
 
 // TODO: F_CREDS_UID
@@ -180,14 +244,30 @@
 //       setting this UID and the caller's default GID as only available 
credentials
 //
 // TODO: F_CREDS_NOBODY
-//       implement the same function setting nobody/nogroup as credentials
+//       implement the same function setting nobody/nobody as credentials
 //
 // TODO: F_CREDS_AEGIS_LIBCREDS --- make this function #ifdef'ed
 
 credentials_t::credentials_t(const QDBusMessage &message)
+: uid("nobody"), gid("nobody")
 {
 #if F_CREDS_AEGIS_LIBCREDS
   *this = Aegis::credentials_from_dbus_connection(message) ;
+#elif F_CREDS_UID
+  QString sender = message.service() ;
+  uint32_t user_id = get_name_owner_from_dbus_sync(Maemo::Timed::bus(), 
sender) ;
+
+  if (user_id == ~0u)
+    log_warning("can't get user (uid) of the caller, already terminated?") ;
+  else
+  {
+    passwd *info = getpwuid(user_id) ;
+    if (info)
+    {
+      uid = info->pw_name ;
+      gid = gidToName(info->pw_gid) ;
+    }
+  }
 #else
 #error credentials_t;:from_dbus_connection is only implemented for aegis
 #endif
--- src/server/credentials.h
+++ src/server/credentials.h
@@ -33,7 +33,6 @@
 using namespace std ;
 
 #include <sys/types.h>
-#include <sys/creds.h>
 #include <QDBusMessage>
 #include <QDBusConnection>
 
@@ -46,9 +45,10 @@
   string uid, gid ;
   set<string> tokens ;
 
-  // TODO: make nobody/nogroup run-time option: /etc/timed.rc
-  credentials_t() : uid("nobody"), gid("nogroup") { }
+  // TODO: make nobody/nobody run-time option: /etc/timed.rc
+  credentials_t() : uid("nobody"), gid("nobody") { }
   credentials_t(const credentials_t &x) : uid(x.uid), gid(x.gid), 
tokens(x.tokens) { }
+  credentials_t(const string &u, const string &g) : uid(u), gid(g) { }
 
   bool apply() const ; // set the credentials for the current process
   bool apply_and_compare() ; // set the credentials and check if they are 
really set
--- src/server/f.h
+++ src/server/f.h
@@ -27,6 +27,7 @@
 #if __MEEGO__
 #  define F_CREDS_UID 1
 //#  define F_CREDS_NOBODY 1
+#  define F_FORCE_DEBUG_PATH "/var/cache/timed/DEBUG"
 #endif
 
 #if __HARMATTAN__
--- src/server/main.cpp
+++ src/server/main.cpp
@@ -41,8 +41,8 @@
 
   // fprintf(stderr, "getcwd returned '%s'", p?cwd:"(null)") ;
 
-  int syslog_level = qmlog::Full ;
-  int varlog_level = qmlog::Full ;
+  int syslog_level = qmlog::Warning ;
+  int varlog_level = qmlog::Warning ;
 
   bool enable_qmlog = true ;
 
--- src/server/server.pro
+++ src/server/server.pro
@@ -14,10 +14,13 @@
 
 IODATA_TYPES = queue.type config.type settings.type customization.type 
tzdata.type
 
-SOURCES += dsme-mode.cpp
-HEADERS += dsme-mode.h
+CONFIG(dsme_dbus_if) {
+    SOURCES += dsme-mode.cpp
+    HEADERS += dsme-mode.h interfaces.h
+    DEFINES += HAVE_DSME
+}
 
-HEADERS += peer.h settings.h csd.h interfaces.h adaptor.h timed.h state.h 
cluster.h machine.h singleshot.h pinguin.h unix-signal.h onitz.h
+HEADERS += peer.h settings.h csd.h adaptor.h timed.h state.h cluster.h 
machine.h singleshot.h pinguin.h unix-signal.h onitz.h
 SOURCES += peer.cpp tzdata.cpp cellular.cpp csd.cpp cluster.cpp machine.cpp 
state.cpp main.cpp timed.cpp timeutil.cpp event.cpp misc.cpp settings.cpp 
pinguin.cpp unix-signal.cpp onitz.cpp
 
 SOURCES += credentials.cpp aegis.cpp
@@ -33,7 +36,11 @@
 HEADERS += notification.h
 
 CONFIG += link_pkgconfig iodata
-PKGCONFIG += contextprovider-1.0 libpcrecpp dsme_dbus_if
+PKGCONFIG += contextprovider-1.0 libpcrecpp
+
+CONFIG(dsme_dbus_if) {
+    PKGCONFIG += dsme_dbus_if
+}
 
 target.path = $$(DESTDIR)/usr/bin
 
@@ -64,7 +71,13 @@
 timedrc.files = timed.rc
 timedrc.path  = $$(DESTDIR)/etc
 
-INSTALLS += target xml backupconf backupscripts cud rfs aegishelper aegisfs 
timedrc
+dbusconf.files = timed.conf
+dbusconf.path  = $$(DESTDIR)/etc/dbus-1/system.d
+
+systemd.files = timed.service
+systemd.path = $$(DESTDIR)/lib/systemd/system
+
+INSTALLS += target xml backupconf backupscripts cud rfs aegishelper aegisfs 
timedrc dbusconf systemd
 
 CONFIG(MEEGO) \
 {
@@ -80,4 +93,4 @@
   QMAKE_CXXFLAGS  += -Wall -Wno-psabi
 }
 
-QMAKE_CXXFLAGS  += -Wall -Werror
+QMAKE_CXXFLAGS  += -Wall
--- src/server/settings.cpp
+++ src/server/settings.cpp
@@ -186,6 +186,8 @@
   p->flag_auto_dst = auto_dst ;
   p->flag_format_24 = format_24 ;
 
+  // check whether we need to "bring old time" to more present
+  o->init_first_boot_hwclock_time_adjustment_check();
   log_assert(Maemo::Timed::WallClock::TimezoneManual==0) ;
   p->zones.push_back(string_std_to_q(manual_zone->zone())) ;
   log_assert(Maemo::Timed::WallClock::TimezoneCellular==1) ;
--- src/server/timed.conf
+++ src/server/timed.conf
@@ -0,0 +1,14 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 
1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+<busconfig>
+
+  <policy user="root">
+    <allow own="com.nokia.time"/>
+    <allow own="com.nokia.timed.backup"/>
+  </policy>
+
+  <policy context="default">
+    <allow send_destination="com.nokia.time"/>
+  </policy>
+
+</busconfig>
--- src/server/timed.cpp
+++ src/server/timed.cpp
@@ -41,7 +41,9 @@
 #include "customization.type.h"
 #include "settings.type.h"
 
+#if HAVE_DSME
 #include "interfaces.h"
+#endif
 #include "adaptor.h"
 #include "backup.h"
 #include "timed.h"
@@ -50,6 +52,13 @@
 #include "tzdata.h"
 #include "csd.h"
 #include "notification.h"
+#include "time.h"
+
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <iomanip>
 
 static void spam()
 {
@@ -91,6 +100,7 @@
 {
   spam() ;
   halted = "" ; // XXX: remove it, as we don't want to halt anymore
+  first_boot_date_adjusted = false;
   log_debug() ;
 
   init_scratchbox_mode() ;
@@ -141,10 +151,16 @@
   init_session_bus() ;
   log_debug() ;
 
+  init_first_boot_hwclock_time_adjustment_check();
+  log_debug() ;
+
   init_load_events() ;
   log_debug() ;
 
+#if F_CSD
   init_cellular_services() ;
+#endif // F_CSD
+
   log_debug() ;
 
   init_network_events() ;
@@ -201,7 +217,7 @@
   }
   log_info("%s" "SCRATCHBOX detected", scratchbox_mode ? "" : "no ") ;
 #else
-  scratcbox_mode = false ;
+  scratchbox_mode = false ;
 #endif
 }
 
@@ -315,9 +331,11 @@
 void Timed::init_device_mode()
 {
   current_mode = "(unknown)" ;
+#if HAVE_DSME
   dsme_mode_handler = new dsme_mode_t ;
   QObject::connect(dsme_mode_handler, SIGNAL(mode_is_changing()), this, 
SLOT(dsme_mode_is_changing())) ;
   QObject::connect(dsme_mode_handler, SIGNAL(mode_reported(const string &)), 
this, SLOT(dsme_mode_reported(const string &))) ;
+#if F_ACTING_DEAD
   if (scratchbox_mode)
   {
     int is_act_dead = is_act_dead_by_status_files() ;
@@ -327,7 +345,11 @@
     device_mode_reached(user_mode) ;
   }
   else
+#endif
+  {
     dsme_mode_handler->init_request() ;
+  }
+#endif
   const char *startup_path="/com/nokia/startup/signal", 
*startup_iface="com.nokia.startup.signal" ;
   const char *desktop_visible_slot = SLOT(harmattan_desktop_visible()) ;
   const char *init_done_slot = SLOT(harmattan_init_done(int)) ;
@@ -650,6 +672,7 @@
   am->start() ;
 }
 
+#if F_CSD
 void Timed::init_cellular_services()
 {
 #if 0
@@ -676,6 +699,7 @@
   QObject::connect(nitz_object, SIGNAL(cellular_data_received(const 
cellular_info_t &)), tz_oracle, SLOT(nitz_data(const cellular_info_t &))) ;
 #endif
 }
+#endif // F_CSD
 
 void Timed::init_network_events()
 {
@@ -813,6 +837,7 @@
 
 void Timed::send_next_bootup_event(int value)
 {
+#if HAVE_DSME
   QDBusConnection dsme = QDBusConnection::systemBus() ;
   QString path = Maemo::Timed::objpath() ;
   QString iface = Maemo::Timed::interface() ;
@@ -823,6 +848,7 @@
     log_info("signal %s(%d) sent", string_q_to_std(signal).c_str(), value) ;
   else
     log_error("Failed to send the signal %s(%d) on system bus: %s", 
string_q_to_std(signal).c_str(), value, 
dsme.lastError().message().toStdString().c_str()) ;
+#endif
 }
 
 void Timed::event_queue_changed()
@@ -1076,6 +1102,7 @@
   time_operational_p->setValue(true) ;
 }
 
+#if HAVE_DSME
 void Timed::dsme_mode_is_changing()
 {
   log_notice("mode is changing, freezeng machine") ;
@@ -1107,6 +1134,7 @@
   start_voland_watcher() ;
 #endif
 }
+#endif
 
 void Timed::connect_to_session_bus(const string &session_bus_address)
 {
@@ -1234,3 +1262,99 @@
   log_notice("KERNEL: system time changed by %s", jump_forwards.str().c_str()) 
;
   settings->process_kernel_notification(jump_forwards) ;
 }
+
+#define CONST_FIRST_BOOT_DATE_FILE        
"/var/cache/timed/first-boot-hwclock.dat"
+
+template <class NumberDataType>
+static bool convert_str_to_number(NumberDataType& res, const string& str, 
ios_base& (*fmt)(ios_base&))
+{
+        istringstream instream(str);
+       return !(instream >> fmt >> res).fail();
+}
+
+static int parse_year_from_date_str(string dataline, int *err_flg_param) {
+        stringstream   ss(dataline);
+        string         item;
+        int             ii;
+        int             val;
+        int             err_flg;
+        int             ret_val;
+
+        ii      = 0;
+        ret_val = -1;
+        *err_flg_param = -1;
+        while(getline(ss, item, ' ')) {
+               if (ii == 3) {
+                       // parse year
+                       err_flg = convert_str_to_number<int>(val, item, dec);
+                       if (err_flg != 0) {
+                               ret_val = val;
+                                *err_flg_param = 0;
+                                break;
+                       }
+               }
+               ii++;
+       }
+        return ret_val;
+}
+
+static int parse_year_from_date_file(const char *date_fname, int *err_flg) {
+        ifstream       in;
+        string         line;
+        int             ret_val;
+
+        ret_val = -1;
+        *err_flg = -1;
+        in.open(date_fname);
+        if (in.is_open() == true) {
+                getline(in, line);
+               if (line.empty() == false) {
+                        ret_val = parse_year_from_date_str(line, err_flg);
+                }
+        }
+        return ret_val;
+}
+
+void Timed::init_first_boot_hwclock_time_adjustment_check() {
+        int     err_flg;
+        int     old_year;
+
+        //time_t  tt;
+        //time(&tt);
+        //log_info("time at timed boottime: %ld", tt);
+        if (first_boot_date_adjusted == false) {
+                if (access(CONST_FIRST_BOOT_DATE_FILE, R_OK) != 0) {
+                        /* first boot date file not found, try to create one...
+                           Check that we can execute this succesfully before 
putting output to file:
+                           (wont neccessarily work at boot time if /dev/rtc0 
is not yet populated by udev
+                        */
+                        err_flg = system("hwclock -r");
+                        if (err_flg == 0) {
+                                err_flg = system("hwclock -r -u > 
/var/cache/timed/first-boot-hwclock.dat");
+                                if (err_flg == 0) {
+                                        old_year    = 
parse_year_from_date_file(CONST_FIRST_BOOT_DATE_FILE, &err_flg);
+                                        if (err_flg == 0) {
+                                                if (old_year < 2011) {
+                                                        // lets udpdate year 
because it's first boot and old year older than 2011
+                                                        
settings->set_system_time(1304244403);
+                                                        log_info("first boot, 
old date from year %d updated to 05/01/2011", old_year);
+                                                        
first_boot_date_adjusted        = true;
+                                                }
+                                        }
+                                        else {
+                                                log_error("Failed to read 
current year from %s", CONST_FIRST_BOOT_DATE_FILE);
+                                        }
+                                }
+                                else {
+                                        log_error("Failed to execute: hwclock 
-r -u > %s", CONST_FIRST_BOOT_DATE_FILE);
+                                }
+                        }
+                        else {
+                                log_error("Failed to execute: 'hwclock -r', 
maybe /dev/rtc0 is not yet available.");
+                        }
+                }
+                else {
+                        first_boot_date_adjusted        = true;
+                }
+        }
+}
--- src/server/timed.h
+++ src/server/timed.h
@@ -46,7 +46,9 @@
 #include "csd.h"
 #include "event.h"
 #include "peer.h"
+#if HAVE_DSME
 #include "dsme-mode.h"
+#endif
 #include "notification.h"
 
 struct Timed : public QCoreApplication
@@ -75,11 +77,13 @@
 
   bool nitz_supported ;
   string tz_by_default ;
+  bool first_boot_date_adjusted;
 
 public:
   bool is_nitz_supported() { return nitz_supported ; }
   const string &default_timezone() { return tz_by_default ; }
   const string &get_settings_path() { return settings_path ; }
+  void init_first_boot_hwclock_time_adjustment_check();
 
 private:
 
@@ -163,7 +167,9 @@
   unsigned ping_period, ping_max_num ;
   string events_path, settings_path ;
   int default_gmt_offset ;
+#if HAVE_DSME
   dsme_mode_t *dsme_mode_handler ;
+#endif
   std::string current_mode ;
   void load_rc() ;
   void load_settings() ;
@@ -194,8 +200,10 @@
 private Q_SLOTS:
   void queue_threshold_timeout() ;
   void unix_signal(int signo) ;
+#if HAVE_DSME
   void dsme_mode_reported(const string &mode) ;
   void dsme_mode_is_changing() ;
+#endif
   void harmattan_init_done(int runlevel) ;
   void harmattan_desktop_visible() ;
   void harmattan_session_started() ;
--- src/server/timed.service
+++ src/server/timed.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Time Daemon
+After=syslog.target
+
+[Service]
+ExecStart=/usr/bin/timed
+
+[Install]
+WantedBy=multi-user.target
--- src/simple-client/simple-client.pro
+++ src/simple-client/simple-client.pro
@@ -9,7 +9,7 @@
 INCLUDEPATH += ../h
 
 QMAKE_LIBDIR_FLAGS += -L../lib -L../voland
-LIBS += -ltimed -ltimed-voland
+LIBS += -ltimed -ltimed-voland -lqmlog
 
 CONFIG += iodata
 
--- src/ticker/ticker.h
+++ src/ticker/ticker.h
@@ -91,6 +91,7 @@
 
   return formatted ;
 }
+#if USE_CELLULAR_QT
 static string csd_network_time_info_to_string(const Cellular::NetworkTimeInfo 
&nti)
 {
   if (not nti.isValid())
@@ -120,7 +121,7 @@
 
   return os.str() ;
 }
-
+#endif // USE_CELLULAR_QT
 
 class ticker : public QCoreApplication
 {
@@ -159,6 +160,7 @@
     else
       log_critical("not connected to D-Bus signal, no time change signal will 
be delivered!") ;
 
+#if HAVE_DSME
     QDBusConnection dsme_bus = QDBusConnection::systemBus() ;
     QString path = Maemo::Timed::objpath() ;
     QString iface = Maemo::Timed::interface() ;
@@ -168,6 +170,7 @@
       log_notice("connected to system bus signal '%s'", 
signal.toStdString().c_str()) ;
     else
       log_critical("not connected to system bus signal 
'%s'",signal.toStdString().c_str()) ;
+#endif
 
 #if USE_CELLULAR_QT
     cellular_time = new Cellular::NetworkTime ;
@@ -242,6 +245,7 @@
     cout << endl ;
     log_notice("Settings change signalled (system time %schanged), new 
settings: %s", time ? "" : "not ", info.str().toStdString().c_str()) ;
   }
+#if HAVE_DSME
   void dsme(int value)
   {
     ostringstream os ;
@@ -254,6 +258,7 @@
     cout << endl ;
     log_notice("%s", os.str().c_str()) ;
   }
+#endif
 #if NEW_CELLULAR
 
 #if NEW_CELLULAR_BROKEN_SIGNAL
--- src/ticker/ticker.pro
+++ src/ticker/ticker.pro
@@ -9,7 +9,7 @@
 INCLUDEPATH += ../h
 
 QMAKE_LIBDIR_FLAGS += -L../lib
-LIBS += -ltimed
+LIBS += -ltimed -lqmlog
 
 SOURCES = ticker.cpp
 HEADERS = ticker.h
@@ -31,4 +31,8 @@
   QMAKE_CXXFLAGS  += -Wall -Wno-psabi
 }
 
-QMAKE_CXXFLAGS  += -Wall -Werror
+CONFIG(dsme_dbus_if) {
+    DEFINES += HAVE_DSME
+}
+
+QMAKE_CXXFLAGS  += -Wall
--- src/voland/interface.h
+++ src/voland/interface.h
@@ -54,7 +54,7 @@
       }
       inline QDBusConnection bus()
       {
-        return QDBusConnection::sessionBus() ;
+        return QDBusConnection::systemBus() ;
       }
       class Interface : public QDBusAbstractInterface
       {

++++++ timed.yaml
--- timed.yaml
+++ timed.yaml
@@ -1,26 +1,12 @@
 Name: timed
 Summary: Time daemon
-Version: 2.54
+Version: 2.55
 Release: 1
 Group: System/System Control
 License: LGPLv2
-URL: http://meego.gitorious.org/meego-middleware/timed
+URL: https://github.com/nemomobile/timed
 Sources:
     - "meego-middleware-%{name}-%{version}.tar.gz"
-    - "%{name}.conf"
-    - "%{name}.service"
-Patches:
-    - "%{name}-2.11-run-as-system-service.patch"
-    - "%{name}-2.27-debugflag-fix.patch"
-    - "%{name}-2.27-typofix.patch"
-    - "%{name}-2.37-cellular-separation.patch"
-    - "%{name}-2.37-uid-creds.patch"
-    - "%{name}-2.53-BMC17566-update-old-date-on-first-boot.patch"
-    - "%{name}-2.53-no-werror.patch"
-    - "lower-server-loglevel.patch"
-    - "%{name}-2.53-no-docs.patch"
-    - "timed-2.53-disable-dsme.patch"
-    - timed-2.54-add-missing-libs-for-linking.patch
 Description: |
     The time daemon (%{name}) managing system time, time zone and settings,
     executing actions at given time and managing the event queue.
@@ -36,10 +22,11 @@
     - contextprovider-1.0
     - libpcrecpp
     - QtCore >= 4.7
+    - dsme_dbus_if
 Configure: none
 Builder: qmake
 QMakeOptions:
-    - -recursive "CONFIG += MEEGO"
+    - -recursive "CONFIG += MEEGO dsme_dbus_if"
 SubPackages:
     - Name: tests
       Summary: Test cases for %{name}

++++++ deleted files:
--- lower-server-loglevel.patch
--- timed-2.11-run-as-system-service.patch
--- timed-2.27-debugflag-fix.patch
--- timed-2.27-typofix.patch
--- timed-2.37-cellular-separation.patch
--- timed-2.37-uid-creds.patch
--- timed-2.53-BMC17566-update-old-date-on-first-boot.patch
--- timed-2.53-disable-dsme.patch
--- timed-2.53-no-docs.patch
--- timed-2.53-no-werror.patch
--- timed-2.54-add-missing-libs-for-linking.patch
--- timed.conf
--- timed.service



Reply via email to