summaryrefslogtreecommitdiffabout
path: root/src/eyefiservice.cc
Unidiff
Diffstat (limited to 'src/eyefiservice.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyefiservice.cc1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/eyefiservice.cc b/src/eyefiservice.cc
index 30c06fa..97cb33b 100644
--- a/src/eyefiservice.cc
+++ b/src/eyefiservice.cc
@@ -91,65 +91,64 @@ int eyefiService::MarkLastPhotoInRoll(
91#endif 91#endif
92 std::string cmd = eyekinfig_t(macaddress).get_on_mark_last_photo_in_roll(); 92 std::string cmd = eyekinfig_t(macaddress).get_on_mark_last_photo_in_roll();
93 if(!cmd.empty()) { 93 if(!cmd.empty()) {
94 if(detached_child()) { 94 if(detached_child()) {
95 putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); 95 putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) );
96 putenv( gnu::autosprintf("EYEFI_MERGEDELTA=%d",mergedelta) ); 96 putenv( gnu::autosprintf("EYEFI_MERGEDELTA=%d",mergedelta) );
97 char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; 97 char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 };
98 execv("/bin/sh",argv); 98 execv("/bin/sh",argv);
99 syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str()); 99 syslog(LOG_ERR,"Failed to execute '%s'",cmd.c_str());
100 _exit(-1); 100 _exit(-1);
101 } 101 }
102 } 102 }
103 return SOAP_OK; 103 return SOAP_OK;
104} 104}
105 105
106int eyefiService::UploadPhoto( 106int eyefiService::UploadPhoto(
107 int fileid, std::string macaddress, 107 int fileid, std::string macaddress,
108 std::string filename, long filesize, std::string filesignature, 108 std::string filename, long filesize, std::string filesignature,
109 std::string encryption, int flags, 109 std::string encryption, int flags,
110 struct rns__UploadPhotoResponse& r ) { 110 struct rns__UploadPhotoResponse& r ) {
111#ifndef NDEBUG 111#ifndef NDEBUG
112 syslog(LOG_DEBUG, 112 syslog(LOG_DEBUG,
113 "UploadPhoto request from %s with fileid=%d, filename=%s, filesize=%ld," 113 "UploadPhoto request from %s with fileid=%d, filename=%s, filesize=%ld,"
114 " filesignature=%s, encryption=%s, flags=%04X", 114 " filesignature=%s, encryption=%s, flags=%04X",
115 macaddress.c_str(), fileid, filename.c_str(), filesize, 115 macaddress.c_str(), fileid, filename.c_str(), filesize,
116 filesignature.c_str(), encryption.c_str(), flags ); 116 filesignature.c_str(), encryption.c_str(), flags );
117#endif 117#endif
118 eyekinfig_t eyekinfig(macaddress); 118 eyekinfig_t eyekinfig(macaddress);
119 119
120 umask(eyekinfig.get_umask()); 120 umask(eyekinfig.get_umask());
121 121
122 std::string td = eyekinfig.get_targetdir(); 122 std::string td = eyekinfig.get_targetdir();
123 /* TODO: try to create, if needed */
124 tmpdir_t indir(td+"/.incoming.XXXXXX"); 123 tmpdir_t indir(td+"/.incoming.XXXXXX");
125 124
126 for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) { 125 for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) {
127#ifndef NDEBUG 126#ifndef NDEBUG
128 syslog(LOG_DEBUG, 127 syslog(LOG_DEBUG,
129 " MIME attachment with id=%s, type=%s, size=%ld", 128 " MIME attachment with id=%s, type=%s, size=%ld",
130 (*i).id, (*i).type, (long)(*i).size ); 129 (*i).id, (*i).type, (long)(*i).size );
131#endif 130#endif
132 131
133#ifndef NDEBUG 132#ifndef NDEBUG
134 if((*i).id && !strcmp((*i).id,"INTEGRITYDIGEST")) { 133 if((*i).id && !strcmp((*i).id,"INTEGRITYDIGEST")) {
135 std::string idigest((*i).ptr,(*i).size); 134 std::string idigest((*i).ptr,(*i).size);
136 syslog(LOG_DEBUG, " INTEGRITYDIGEST=%s", idigest.c_str()); 135 syslog(LOG_DEBUG, " INTEGRITYDIGEST=%s", idigest.c_str());
137 } 136 }
138#endif 137#endif
139 if( (*i).id && !strcmp((*i).id,"FILENAME") ) { 138 if( (*i).id && !strcmp((*i).id,"FILENAME") ) {
140 assert( (*i).type && !strcmp((*i).type,"application/x-tar") ); 139 assert( (*i).type && !strcmp((*i).type,"application/x-tar") );
141#ifdef III_SAVE_TARS 140#ifdef III_SAVE_TARS
142 std::string tarfile = indir.get_file(filename); 141 std::string tarfile = indir.get_file(filename);
143 { 142 {
144 std::ofstream(tarfile.c_str(),std::ios::out|std::ios::binary).write((*i).ptr,(*i).size); 143 std::ofstream(tarfile.c_str(),std::ios::out|std::ios::binary).write((*i).ptr,(*i).size);
145 } 144 }
146#endif 145#endif
147 tarchive_t a((*i).ptr,(*i).size); 146 tarchive_t a((*i).ptr,(*i).size);
148 if(!a.read_next_header()) 147 if(!a.read_next_header())
149 throw std::runtime_error("failed to tarchive_t::read_next_header())"); 148 throw std::runtime_error("failed to tarchive_t::read_next_header())");
150 std::string jf = indir.get_file(a.entry_pathname()); 149 std::string jf = indir.get_file(a.entry_pathname());
151 std::string::size_type ls = jf.rfind('/'); 150 std::string::size_type ls = jf.rfind('/');
152 std::string jbn = (ls==std::string::npos)?jf:jf.substr(ls+1); 151 std::string jbn = (ls==std::string::npos)?jf:jf.substr(ls+1);
153 int fd=open(jf.c_str(),O_CREAT|O_WRONLY,0666); 152 int fd=open(jf.c_str(),O_CREAT|O_WRONLY,0666);
154 assert(fd>0); 153 assert(fd>0);
155 a.read_data_into_fd(fd); 154 a.read_data_into_fd(fd);