summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-06-28 23:29:27 +0000
committerRené Schümann <white06tiger@gmail.com>2014-06-28 23:29:27 +0000
commit814ff2e2b838bdefb42f2af358f358446025c8d0 (patch)
tree78ff09fb8b3748f4a308491d9c4ac2e11dc9610b /plugins/SendScreenshotPlus/src
parentc6e1bedfc18495b3e083069f8d03c2218f6f6b78 (diff)
SendSS v0.8.6.0:
+ imgur.com support by user requests (anonymous upload only) (CSendHost_imgur,CSend,global.h,UMainForm) this also include basic functions for JSON parsing (currently only JSON without spaces and arrays) (CSend) SSL/HTTPS support for HTTPFormCreate (CSend) support for custom headers in HTTPFormCreate (CSend) * updated ImageShack related filenames. * very minor misc code changes and improvements (comments, error messages) git-svn-id: http://svn.miranda-ng.org/main/trunk@9606 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus/src')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp148
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h13
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp (renamed from plugins/SendScreenshotPlus/src/CSendImageShack.cpp)21
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h (renamed from plugins/SendScreenshotPlus/src/CSendImageShack.h)6
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp95
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.h28
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.h1
-rw-r--r--plugins/SendScreenshotPlus/src/global.h3
-rw-r--r--plugins/SendScreenshotPlus/src/version.h4
12 files changed, 307 insertions, 26 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index f0c800004e..cb18639223 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -462,6 +462,140 @@ const char* CSend::GetHTMLContent(char* str, const char* startTag, const char* e
}
return begin;
}
+int JSON_ParseData_(const char** jsondata,size_t jsonlen,const char** rawdata){
+ const char* c=*jsondata;
+ const char* jsonend=*jsondata+jsonlen;
+ int len=0;
+ *rawdata=NULL;
+ if(c==jsonend)
+ return 0;
+ if(*c=='{'){ // scope (object)
+ *rawdata=c;
+ do{
+ if(*c=='{') ++len;
+ else if(*c=='}') --len;
+ if(++c==jsonend)
+ return 0;
+ }while(len>0);
+ len=c-*rawdata;
+ if(*c==',') ++c;
+ }else if(*c=='"' || *c=='\''){ // string
+ char needle=*c;
+ if(++c==jsonend)
+ return 0;
+ *rawdata=c;
+ do{
+ if(c==jsonend || (*c=='\\' && ++c==jsonend))
+ return 0;
+ }while(*c++!=needle);
+ len=c-*rawdata-1;
+ if(*c==',') ++c;
+ }else{ // other
+ for(*rawdata=c; c<jsonend && *c++!=','; );
+ len=c-*rawdata;
+ if(c[-1]==',') --len;
+ }
+ *jsondata=c;
+ return len;
+}
+int JSON_Get_(const char* json, size_t jsonlen, const char* variable, const char** value) {
+ char needle[32];
+ const char* needlechild;
+ char var[32];
+ char* tmp;
+ const char* c;
+ const char* jsonend=json+jsonlen;
+ /// get needle
+ if(!jsonlen || *json!='{')
+ return 0;
+ for(tmp=needle,c=*variable=='['?variable+1:variable; *c!='[' && *c!=']'; ++c){
+ if(c==jsonend)
+ return 0;
+ if(tmp<needle+sizeof(needle)-1) *tmp++=*c;
+ }
+ *tmp='\0';
+ /// get child needle (if any)
+ if(*c==']') ++c;
+ if(c==jsonend)
+ return 0;
+ needlechild=c;
+ /// parse JSON
+ for(c=json+1; c<jsonend && (*c=='"' || *c=='\''); ){
+ for(++c,tmp=var; c<jsonend && (*c!='"' && *c!='\''); ++c)
+ if(tmp<var+sizeof(var)-1) *tmp++=*c;
+ *tmp='\0';
+ if(c+2>=jsonend || *++c!=':') break;
+ /// read data
+ ++c;
+ if(!strcmp(var,needle)){
+ int datalen=JSON_ParseData_(&c,jsonend-c,value);
+ if(!datalen)
+ return 0;
+ if(*needlechild && **value=='{'){ // we need a child value, parse child object
+ return JSON_Get_(*value,datalen,needlechild,value);
+ }
+ return datalen;
+ }else{
+ JSON_ParseData_(&c,jsonend-c,value);
+ }
+ }
+ *value=NULL;
+ return 0;
+}
+int CSend::GetJSONString(const char* json, size_t jsonlen, const char* variable, char* value, size_t valuesize) {
+ if(!jsonlen || !valuesize)
+ return 0;
+ const char* rawvalue;
+ int rawlen=JSON_Get_(json,jsonlen,variable,&rawvalue);
+ if(rawlen){
+ size_t out=0;
+ --valuesize;
+ /// copy & parse escape sequences
+ for(int in=0; in<rawlen && out<valuesize; ++in,++out){
+ if(rawvalue[in]=='\\'){
+ if(++in==rawlen)
+ break;
+ switch(rawvalue[in]){
+ case 's': value[out]=' '; break;
+ case 't': value[out]='\t'; break;
+ case 'n': value[out]='\n'; break;
+ case 'r': value[out]='\r'; break;
+ default: value[out]=rawvalue[in];
+ }
+ continue;
+ }
+ value[out]=rawvalue[in];
+ }
+ value[out]='\0';
+ return 1;
+ }
+ *value='\0';
+ return 0;
+}
+int CSend::GetJSONInteger(const char* json, size_t jsonlen, const char* variable,int defvalue) {
+ const char* rawvalue;
+ int rawlen=JSON_Get_(json,jsonlen,variable,&rawvalue);
+ if(rawlen){
+ defvalue=0;
+ for(int offset=0; offset<rawlen; ++offset){
+ if(rawvalue[offset]<'0' || rawvalue[offset]>'9') break;
+ defvalue*=10;
+ defvalue+=rawvalue[offset]-'0';
+ }
+ }
+ return defvalue;
+}
+bool CSend::GetJSONBool(const char* json, size_t jsonlen, const char* variable) {
+ const char* rawvalue;
+ int rawlen=JSON_Get_(json,jsonlen,variable,&rawvalue);
+ if(rawlen){
+ if(rawlen==4 && !memcmp(rawvalue,"true",4))
+ return true;
+ if(*rawvalue>'0' && *rawvalue<='9')
+ return true;
+ }
+ return false;
+}
static void HTTPFormAppendData(NETLIBHTTPREQUEST* nlhr, size_t* dataMax, char** dataPos, const char* data,size_t len){
nlhr->dataLength=(*dataPos-nlhr->pData);
@@ -505,8 +639,13 @@ int CSend::HTTPFormCreate(NETLIBHTTPREQUEST* nlhr,int requestType,char* url,HTTP
nlhr->cbSize =sizeof(NETLIBHTTPREQUEST);
nlhr->requestType =requestType;
nlhr->flags =NLHRF_HTTP11;
+ if(!strncmp(url,"https://",8)) nlhr->flags|=NLHRF_SSL;
nlhr->szUrl =url;
nlhr->headersCount =3;
+ for(HTTPFormData* iter=frm,* end=frm+frmNum; iter!=end; ++iter){
+ if(!(iter->flags&HTTPFF_HEADER)) break;
+ ++nlhr->headersCount;
+ }
nlhr->headers =(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr->headersCount);
{
char* contenttype=(char*)mir_alloc(sizeof(char)*(30+1+sizeof(boundary)));
@@ -519,12 +658,17 @@ int CSend::HTTPFormCreate(NETLIBHTTPREQUEST* nlhr,int requestType,char* url,HTTP
nlhr->headers[1].szValue =__USER_AGENT_STRING;
nlhr->headers[2].szName ="Accept-Language";
nlhr->headers[2].szValue ="en-us,en;q=0.8";
-// nlhr->headers[3].szName ="Referer";
-// nlhr->headers[3].szValue ="http://www.imageshack.us/upload_api.php";
+ int i=3;
+ for(HTTPFormData* iter=frm,* end=frm+frmNum; iter!=end; ++iter){
+ if(!(iter->flags&HTTPFF_HEADER)) break;
+ nlhr->headers[i].szName=(char*)iter->name;
+ nlhr->headers[i++].szValue=(char*)iter->value_str;
+ }
}
char* dataPos=nlhr->pData;
size_t dataMax=0;
for(HTTPFormData* iter=frm,* end=frm+frmNum; iter!=end; ++iter){
+ if(iter->flags&HTTPFF_HEADER) continue;
HTTPFormAppendData(nlhr,&dataMax,&dataPos,NULL,2+sizeof(boundary)+40);
memset(dataPos,'-',2); dataPos+=2;
memcpy(dataPos,boundary,sizeof(boundary)); dataPos+=sizeof(boundary);
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index 16ab0f192e..e9e57a9199 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -42,8 +42,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GC_RESULT_ERROR 202
#define GC_RESULT_NOSESSION 209
-#define SS_ERR_INIT LPGENT("Unable to initiate %s.")
-#define SS_ERR_MAPI LPGENT("MAPI error (%i):\n%s.")
+const TCHAR SS_ERR_INIT[] =LPGENT("Unable to initiate %s.");
+const TCHAR SS_ERR_MAPI[] =LPGENT("MAPI error (%i):\n%s.");
+const TCHAR SS_ERR_RESPONSE[] =LPGENT("Unknown response from %s (%i)");
+const TCHAR SS_ERR_NORESPONSE[] =LPGENT("Got no response from %s (%i)");
//---------------------------------------------------------------------------
class CSend {
@@ -102,15 +104,17 @@ class CSend {
/// HTTP upload helper stuff
enum HTTPFormFlags{
+ HTTPFF_HEADER=0x80,
HTTPFF_TEXT =0x00,
HTTPFF_8BIT =0x01,
HTTPFF_FILE =0x02,
HTTPFF_INT =0x04,
};
+ #define HTTPFORM_HEADER(str) str,HTTPFF_HEADER
#define HTTPFORM_TEXT(str) str,HTTPFF_TEXT
#define HTTPFORM_8BIT(str) str,HTTPFF_8BIT
#define HTTPFORM_FILE(str) str,HTTPFF_FILE
- #define HTTPFORM_INT(int) (const char*)int,HTTPFF_INT
+ #define HTTPFORM_INT(int) (const char*)(int),HTTPFF_INT
struct HTTPFormData{
const char* name;
union{
@@ -120,6 +124,9 @@ class CSend {
int flags;
};
static const char* GetHTMLContent(char* str, const char* startTag, const char* endTag); /// changes "str", can be successfully used only once
+ static int GetJSONString(const char* json, size_t jsonlen, const char* variable, char* value, size_t valuesize);
+ static int GetJSONInteger(const char* json, size_t jsonlen, const char* variable,int defvalue);
+ static bool GetJSONBool(const char* json, size_t jsonlen, const char* variable);
void HTTPFormDestroy(NETLIBHTTPREQUEST* nlhr); /// use to free data inside "nlhr" created by HTTPFormCreate
int HTTPFormCreate(NETLIBHTTPREQUEST* nlhr,int requestType,char* url,HTTPFormData* frm,size_t frmNum); /// returns "0" on success, Exit() will be called on failure (stop processing)
};
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
index 9bd0ef0e0f..b4dc0dde92 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
@@ -30,17 +30,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "global.h"
//---------------------------------------------------------------------------
-CSendImageShack::CSendImageShack(HWND Owner, MCONTACT hContact, bool bAsync)
+CSendHost_ImageShack::CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync)
: CSend(Owner, hContact, bAsync) {
m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
m_pszSendTyp = LPGENT("Image upload");
}
-CSendImageShack::~CSendImageShack(){
+CSendHost_ImageShack::~CSendHost_ImageShack(){
};
//---------------------------------------------------------------------------
-int CSendImageShack::Send() {
+int CSendHost_ImageShack::Send() {
if(!hNetlibUser){ /// check Netlib
Error(SS_ERR_INIT, m_pszSendTyp);
Exit(ACKRESULT_FAILED);
@@ -49,6 +49,7 @@ int CSendImageShack::Send() {
ZeroMemory(&m_nlhr, sizeof(m_nlhr));
char* tmp; tmp=mir_t2a(m_pszFile);
HTTPFormData frm[]={
+// {"Referer",HTTPFORM_HEADER("http://www.imageshack.us/upload_api.php")},
{"fileupload",HTTPFORM_FILE(tmp)},
//{"rembar","yes"},// no info bar on thumb
{"public","no"},
@@ -60,15 +61,15 @@ int CSendImageShack::Send() {
return !m_bAsync;
/// start upload thread
if(m_bAsync){
- mir_forkthread(&CSendImageShack::SendThreadWrapper, this);
+ mir_forkthread(&CSendHost_ImageShack::SendThreadWrapper, this);
return 0;
}
SendThread();
return 1;
}
-void CSendImageShack::SendThread() {
- //send DATA and wait for m_nlreply
+void CSendHost_ImageShack::SendThread() {
+ /// send DATA and wait for m_nlreply
NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&m_nlhr);
HTTPFormDestroy(&m_nlhr);
if(reply){
@@ -104,15 +105,15 @@ void CSendImageShack::SendThread() {
mir_free(err);
}
}else{
- Error(LPGENT("Upload server did not respond timely."));
+ Error(SS_ERR_RESPONSE,m_pszSendTyp,reply->resultCode);
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply);
}else{
- Error(SS_ERR_INIT, m_pszSendTyp);
+ Error(SS_ERR_NORESPONSE,m_pszSendTyp,m_nlhr.resultCode);
}
Exit(ACKRESULT_FAILED);
}
-void CSendImageShack::SendThreadWrapper(void * Obj) {
- reinterpret_cast<CSendImageShack*>(Obj)->SendThread();
+void CSendHost_ImageShack::SendThreadWrapper(void * Obj) {
+ reinterpret_cast<CSendHost_ImageShack*>(Obj)->SendThread();
}
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.h b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h
index f32e1cd0b0..30e1fdaa21 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.h
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h
@@ -30,11 +30,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define _CSEND_IMAGESHACK_H
//---------------------------------------------------------------------------
-class CSendImageShack : public CSend {
+class CSendHost_ImageShack : public CSend {
public:
// Deklaration Standardkonstruktor/Standarddestructor
- CSendImageShack(HWND Owner, MCONTACT hContact, bool bAsync);
- ~CSendImageShack();
+ CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync);
+ ~CSendHost_ImageShack();
int Send();
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
new file mode 100644
index 0000000000..1a4063e710
--- /dev/null
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
@@ -0,0 +1,95 @@
+/*
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2014 Miranda NG project (http://miranda-ng.org)
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+*/
+#include "global.h"
+
+CSendHost_Imgur::CSendHost_Imgur(HWND Owner, MCONTACT hContact, bool bAsync)
+ : CSend(Owner,hContact,bAsync)
+{
+ m_EnableItem=SS_DLG_DESCRIPTION|SS_DLG_AUTOSEND|SS_DLG_DELETEAFTERSSEND;
+ m_pszSendTyp=LPGENT("Image upload");
+}
+
+CSendHost_Imgur::~CSendHost_Imgur()
+{}
+
+//---------------------------------------------------------------------------
+int CSendHost_Imgur::Send()
+{
+ if(!hNetlibUser){ /// check Netlib
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ return !m_bAsync;
+ }
+ ZeroMemory(&m_nlhr, sizeof(m_nlhr));
+ char* tmp; tmp=mir_t2a(m_pszFile);
+ HTTPFormData frm[]={
+ {"Authorization",HTTPFORM_HEADER("Client-ID 2a7303d78abe041")},
+ {"image",HTTPFORM_FILE(tmp)},
+// {"name",""},// filename (detected if multipart / form-data)
+// {"title",""},
+// {"description",""},
+ };
+ int error=HTTPFormCreate(&m_nlhr,REQUEST_POST,"https://api.imgur.com/3/image",frm,sizeof(frm)/sizeof(HTTPFormData));
+ mir_free(tmp);
+ if(error)
+ return !m_bAsync;
+ /// start upload thread
+ if(m_bAsync){
+ mir_forkthread(&CSendHost_Imgur::SendThread, this);
+ return 0;
+ }
+ SendThread(this);
+ return 1;
+}
+
+void CSendHost_Imgur::SendThread(void* obj)
+{
+ CSendHost_Imgur* self=(CSendHost_Imgur*)obj;
+ /// send DATA and wait for m_nlreply
+ NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&self->m_nlhr);
+ self->HTTPFormDestroy(&self->m_nlhr);
+ if(reply){
+ if(reply->dataLength){
+ char buf[128];
+// GetJSONInteger(reply->pData,reply->dataLength,"status",0)
+ if(GetJSONBool(reply->pData,reply->dataLength,"success")){
+// GetJSONString(reply->pData,reply->dataLength,"data[id]",buf,sizeof(buf));
+ GetJSONString(reply->pData,reply->dataLength,"data[link]",buf,sizeof(buf));
+// GetJSONString(reply->pData,reply->dataLength,"[data][deletehash]",buf,sizeof(buf));
+ mir_free(self->m_URL), self->m_URL=mir_strdup(buf);
+ char* ext=strrchr(self->m_URL,'.');
+ if(ext){
+ size_t thumblen=strlen(self->m_URL)+2;
+ mir_free(self->m_URLthumb), self->m_URLthumb=(char*)mir_alloc(thumblen);
+ thumblen=ext-self->m_URL;
+ memcpy(self->m_URLthumb,self->m_URL,thumblen);
+ self->m_URLthumb[thumblen]='m'; // 320x320, see http://api.imgur.com/models/image
+ strcpy(self->m_URLthumb+thumblen+1,self->m_URL+thumblen);
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply);
+ self->svcSendMsgExit(self->m_URL); return;
+ }else{
+ self->Error(SS_ERR_RESPONSE,self->m_pszSendTyp,GetJSONInteger(reply->pData,reply->dataLength,"status",0));
+ }
+ }else{
+ self->Error(SS_ERR_RESPONSE,self->m_pszSendTyp,reply->resultCode);
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply);
+ }else{
+ self->Error(SS_ERR_NORESPONSE,self->m_pszSendTyp,self->m_nlhr.resultCode);
+ }
+ self->Exit(ACKRESULT_FAILED);
+}
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.h b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h
new file mode 100644
index 0000000000..84223ec9f4
--- /dev/null
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h
@@ -0,0 +1,28 @@
+/*
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2014 Miranda NG project (http://miranda-ng.org)
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+*/
+#ifndef _CSEND_HOST_IMGUR_H
+#define _CSEND_HOST_IMGUR_H
+class CSendHost_Imgur : public CSend {
+// API: http://api.imgur.com/endpoints/image
+ public:
+ CSendHost_Imgur(HWND Owner, MCONTACT hContact, bool bAsync);
+ ~CSendHost_Imgur();
+ int Send();
+ protected:
+ NETLIBHTTPREQUEST m_nlhr;
+ static void SendThread(void* obj);
+};
+#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index 6a2c7fe48a..73830c7052 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -63,7 +63,7 @@ int CSendHost_UploadPie::Send()
void CSendHost_UploadPie::SendThread(void* obj)
{
CSendHost_UploadPie* self=(CSendHost_UploadPie*)obj;
- //send DATA and wait for m_nlreply
+ /// send DATA and wait for m_nlreply
NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&self->m_nlhr);
self->HTTPFormDestroy(&self->m_nlhr);
if(reply){
@@ -96,11 +96,11 @@ void CSendHost_UploadPie::SendThread(void* obj)
mir_free(werr);
}
}else{
- self->Error(LPGENT("Upload server did not respond timely."));
+ self->Error(SS_ERR_RESPONSE,self->m_pszSendTyp,reply->resultCode);
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply);
}else{
- self->Error(SS_ERR_INIT, self->m_pszSendTyp);
+ self->Error(SS_ERR_NORESPONSE,self->m_pszSendTyp,self->m_nlhr.resultCode);
}
self->Exit(ACKRESULT_FAILED);
}
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index 58f5f8819e..fc69925c58 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -275,7 +275,7 @@ INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam) {
// lParam = (HANDLE)contact (can be null)
INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam) {
char* result = NULL;
- CSendImageShack* cSend = new CSendImageShack(NULL, lParam, false);
+ CSendHost_ImageShack* cSend = new CSendHost_ImageShack(NULL, lParam, false);
cSend->m_bDeleteAfterSend = false;
cSend->SetFile((char*)wParam);
if (lParam != NULL) {
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index 6abf446e60..859fd0a9cc 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -315,6 +315,7 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Upload Pie (30m)")), SS_UPLOADPIE_30M);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Upload Pie (1d)")), SS_UPLOADPIE_1D);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Upload Pie (1w)")), SS_UPLOADPIE_1W);
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("imgur")), SS_IMGUR);
ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxSendBy); //use Workaround for MS bug ComboBox_SelectItemData
}
/// init footer options
@@ -832,7 +833,7 @@ void TfrmMain::cboxSendByChange() {
m_cSend = new CSendDropbox(m_hWnd, m_hContact, false);
break;
case SS_IMAGESHACK: //"ImageShack"
- m_cSend = new CSendImageShack(m_hWnd, m_hContact, true);
+ m_cSend = new CSendHost_ImageShack(m_hWnd, m_hContact, true);
break;
case SS_UPLOADPIE_30M: //"Upload Pie (30 minutes)"
m_cSend = new CSendHost_UploadPie(m_hWnd, m_hContact, true,1);
@@ -843,6 +844,9 @@ void TfrmMain::cboxSendByChange() {
case SS_UPLOADPIE_1W: //"Upload Pie (1 week)"
m_cSend = new CSendHost_UploadPie(m_hWnd, m_hContact, true,5);
break;
+ case SS_IMGUR:
+ m_cSend = new CSendHost_Imgur(m_hWnd, m_hContact, true);
+ break;
default: //SS_JUSTSAVE - "Just save it "
m_cSend = NULL;
break;
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h
index c5906b2f1d..b6ba02ddd3 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.h
+++ b/plugins/SendScreenshotPlus/src/UMainForm.h
@@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SS_UPLOADPIE_30M 7
#define SS_UPLOADPIE_1D 8
#define SS_UPLOADPIE_1W 9
+#define SS_IMGUR 10
// Used for our own cheap TrackMouseEvent
#define BUTTON_POLLDELAY 50
diff --git a/plugins/SendScreenshotPlus/src/global.h b/plugins/SendScreenshotPlus/src/global.h
index d0914b4a00..9c822d3f98 100644
--- a/plugins/SendScreenshotPlus/src/global.h
+++ b/plugins/SendScreenshotPlus/src/global.h
@@ -90,8 +90,9 @@ using namespace std;
#include "CSendFTPFile.h"
#include "CSendHTTPServer.h"
#include "CSendDropbox.h"
-#include "CSendImageShack.h"
+#include "CSendHost_ImageShack.h"
#include "CSendHost_uploadpie.h"
+#include "CSendHost_imgur.h"
#include "DevKey.h"
#include "UMainForm.h"
#include "UAboutForm.h"
diff --git a/plugins/SendScreenshotPlus/src/version.h b/plugins/SendScreenshotPlus/src/version.h
index 34c726289c..eaf9ca7683 100644
--- a/plugins/SendScreenshotPlus/src/version.h
+++ b/plugins/SendScreenshotPlus/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 8
-#define __RELEASE_NUM 5
-#define __BUILD_NUM 2
+#define __RELEASE_NUM 6
+#define __BUILD_NUM 0
#include <stdver.h>