Move qt_cam_copy_register to QtCamera
[harmattan/cameraplus] / lib / qtcamnotifications.cpp
index a147ade..717e7ae 100644 (file)
@@ -1,7 +1,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include "qtcamnotifications.h"
 #include "qtcamnotifications_p.h"
 #include "qtcamdevice.h"
+#include "qtcamdevice_p.h"
+#include "qtcamimagemode.h"
+#ifndef GST_USE_UNSTABLE_API
+#define GST_USE_UNSTABLE_API
+#endif /* GST_USE_UNSTABLE_API */
+#include <gst/interfaces/photography.h>
 
 QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
   QObject(parent), d_ptr(new QtCamNotificationsPrivate) {
@@ -32,13 +38,13 @@ QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
   d_ptr->imageStart = new QtCamGStreamerMessageHandler("photo-capture-start", this);
   d_ptr->imageEnd = new QtCamGStreamerMessageHandler("photo-capture-end", this);
   d_ptr->videoDone = new QtCamGStreamerMessageHandler("video-done", this);
-
-  d_ptr->af = new QtCamAutoFocus(dev, this);
+  d_ptr->af = new QtCamGStreamerMessageHandler(GST_PHOTOGRAPHY_AUTOFOCUS_DONE, this);
 
   if (d_ptr->listener) {
     d_ptr->listener->addSyncHandler(d_ptr->imageStart);
     d_ptr->listener->addHandler(d_ptr->imageEnd);
     d_ptr->listener->addHandler(d_ptr->videoDone);
+    d_ptr->listener->addHandler(d_ptr->af);
   }
 
   QObject::connect(d_ptr->imageStart, SIGNAL(messageSent(GstMessage *)),
@@ -50,7 +56,13 @@ QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
   QObject::connect(d_ptr->videoDone, SIGNAL(messageSent(GstMessage *)),
                   this, SIGNAL(videoRecordingEnded()), Qt::DirectConnection);
 
-  QObject::connect(d_ptr->af, SIGNAL(statusChanged()), this, SLOT(autoFocusStatusChanged()));
+  QObject::connect(d_ptr->af, SIGNAL(messageSent(GstMessage *)),
+                  this, SLOT(autoFocusStatusChanged(GstMessage *)));
+
+  QObject::connect(d_ptr->imageStart, SIGNAL(messageSent(GstMessage *)),
+                  d_ptr->dev->d_ptr->image, SIGNAL(captureStarted()), Qt::AutoConnection);
+  QObject::connect(d_ptr->imageEnd, SIGNAL(messageSent(GstMessage *)),
+                  d_ptr->dev->d_ptr->image, SIGNAL(captureEnded()), Qt::AutoConnection);
 }
 
 QtCamNotifications::~QtCamNotifications() {
@@ -58,12 +70,13 @@ QtCamNotifications::~QtCamNotifications() {
     d_ptr->listener->removeSyncHandler(d_ptr->imageStart);
     d_ptr->listener->removeHandler(d_ptr->imageEnd);
     d_ptr->listener->removeHandler(d_ptr->videoDone);
+    d_ptr->listener->removeHandler(d_ptr->af);
   }
 
   delete d_ptr->imageStart.data();
   delete d_ptr->imageEnd.data();
-
-  delete d_ptr->af;
+  delete d_ptr->videoDone.data();
+  delete d_ptr->af.data();
 
   delete d_ptr; d_ptr = 0;
 }