~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/libkdcraw/libraw/RawSpeed/CameraMetaData.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "StdAfx.h"
 
2
#include "CameraMetaData.h"
 
3
/*
 
4
    RawSpeed - RAW file decoder.
 
5
 
 
6
    Copyright (C) 2009 Klaus Post
 
7
 
 
8
    This library is free software; you can redistribute it and/or
 
9
    modify it under the terms of the GNU Lesser General Public
 
10
    License as published by the Free Software Foundation; either
 
11
    version 2 of the License, or (at your option) any later version.
 
12
 
 
13
    This library is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
    Lesser General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Lesser General Public
 
19
    License along with this library; if not, write to the Free Software
 
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
21
 
 
22
    http://www.klauspost.com
 
23
*/
 
24
 
 
25
namespace RawSpeed {
 
26
 
 
27
CameraMetaData::CameraMetaData() {
 
28
}
 
29
 
 
30
CameraMetaData::CameraMetaData(char *docname) {
 
31
  ctxt = xmlNewParserCtxt();
 
32
  if (ctxt == NULL) {
 
33
    ThrowCME("CameraMetaData:Could not initialize context.");
 
34
  }
 
35
 
 
36
  xmlResetLastError();
 
37
  doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDVALID);
 
38
 
 
39
  if (doc == NULL) {
 
40
      ThrowCME("CameraMetaData: XML Document could not be parsed successfully. Error was: %s", ctxt->lastError.message);
 
41
  }
 
42
 
 
43
  if (ctxt->valid == 0) {
 
44
    if (ctxt->lastError.code == 0x5e) {
 
45
      printf("CameraMetaData: Unable to locate DTD, attempting to ignore.");
 
46
    } else {
 
47
      ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", ctxt->lastError.message);
 
48
    }
 
49
  }
 
50
 
 
51
  xmlNodePtr cur;
 
52
  cur = xmlDocGetRootElement(doc);
 
53
  if (xmlStrcmp(cur->name, (const xmlChar *) "Cameras")) {
 
54
    ThrowCME("CameraMetaData: XML document of the wrong type, root node is not cameras.");
 
55
    return;
 
56
  }
 
57
 
 
58
  cur = cur->xmlChildrenNode;
 
59
  while (cur != NULL) {
 
60
    if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))) {
 
61
      Camera *camera = new Camera(doc, cur);
 
62
      addCamera(camera);
 
63
 
 
64
      // Create cameras for aliases.
 
65
      for (uint32 i = 0; i < camera->aliases.size(); i++) {
 
66
        addCamera(new Camera(camera, i));
 
67
      }
 
68
    }
 
69
    cur = cur->next;
 
70
  }
 
71
  if (doc)
 
72
    xmlFreeDoc(doc);
 
73
  doc = 0;
 
74
  if (ctxt)
 
75
    xmlFreeParserCtxt(ctxt);
 
76
  ctxt = 0;
 
77
}
 
78
 
 
79
CameraMetaData::~CameraMetaData(void) {
 
80
  map<string, Camera*>::iterator i = cameras.begin();
 
81
  for (; i != cameras.end(); ++i) {
 
82
    delete((*i).second);
 
83
  }
 
84
  if (doc)
 
85
    xmlFreeDoc(doc);
 
86
  doc = 0;
 
87
  if (ctxt)
 
88
    xmlFreeParserCtxt(ctxt);
 
89
  ctxt = 0;
 
90
}
 
91
 
 
92
Camera* CameraMetaData::getCamera(string make, string model, string mode) {
 
93
  string id = string(make).append(model).append(mode);
 
94
  if (cameras.end() == cameras.find(id))
 
95
    return NULL;
 
96
  return cameras[id];
 
97
}
 
98
 
 
99
bool CameraMetaData::hasCamera(string make, string model, string mode) {
 
100
  string id = string(make).append(model).append(mode);
 
101
  if (cameras.end() == cameras.find(id))
 
102
    return FALSE;
 
103
  return TRUE;
 
104
}
 
105
 
 
106
void CameraMetaData::addCamera( Camera* cam )
 
107
{
 
108
  string id = string(cam->make).append(cam->model).append(cam->mode);
 
109
  if (cameras.end() != cameras.find(id))
 
110
    printf("CameraMetaData: Duplicate entry found for camera: %s %s, Skipping!\n", cam->make.c_str(), cam->model.c_str());
 
111
  else
 
112
    cameras[id] = cam;
 
113
}
 
114
 
 
115
} // namespace RawSpeed