Move qt_cam_copy_register to QtCamera
[harmattan/cameraplus] / lib / qtcamnotifications.cpp
index 5b50c0e..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 "qtcamgstreamermessagehandler.h"
-#include "qtcamgstreamermessagelistener.h"
+#include "qtcamnotifications_p.h"
 #include "qtcamdevice.h"
-#include <QPointer>
-
-class QtCamNotificationsPrivate {
-public:
-  QtCamDevice *dev;
-  QPointer<QtCamGStreamerMessageHandler> imageStart;
-  QPointer<QtCamGStreamerMessageHandler> imageEnd;
-
-  QPointer<QtCamGStreamerMessageHandler> videoDone;
-  QPointer<QtCamGStreamerMessageListener> listener;
-};
+#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) {
+
+  d_ptr->q_ptr = this;
   d_ptr->dev = dev;
 
   d_ptr->listener = dev->listener();
   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 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 *)),
@@ -57,6 +55,14 @@ 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(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() {
@@ -64,10 +70,15 @@ 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->videoDone.data();
+  delete d_ptr->af.data();
 
   delete d_ptr; d_ptr = 0;
 }
+
+#include "moc_qtcamnotifications.cpp"