summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/certimportwidget.c62
-rw-r--r--src/ui/inputwidget.c2
-rw-r--r--src/ui/labelwidget.c15
-rw-r--r--src/ui/uploadwidget.c2
4 files changed, 54 insertions, 27 deletions
diff --git a/src/ui/certimportwidget.c b/src/ui/certimportwidget.c
index 65cb6654..f4dfdefa 100644
--- a/src/ui/certimportwidget.c
+++ b/src/ui/certimportwidget.c
@@ -31,6 +31,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
31#include "text.h" 31#include "text.h"
32#include "ui/util.h" 32#include "ui/util.h"
33 33
34#if defined (iPlatformAppleMobile)
35# include "ios.h"
36#endif
37
34#include <the_Foundation/file.h> 38#include <the_Foundation/file.h>
35#include <the_Foundation/tlsrequest.h> 39#include <the_Foundation/tlsrequest.h>
36#include <the_Foundation/path.h> 40#include <the_Foundation/path.h>
@@ -75,7 +79,7 @@ static iBool tryImport_CertImportWidget_(iCertImportWidget *d, const iBlock *dat
75 deinit_String(&pem); 79 deinit_String(&pem);
76 /* Update the labels. */ { 80 /* Update the labels. */ {
77 if (d->cert && !isEmpty_TlsCertificate(d->cert)) { 81 if (d->cert && !isEmpty_TlsCertificate(d->cert)) {
78 setTextCStr_LabelWidget( 82 updateTextCStr_LabelWidget(
79 d->crtLabel, 83 d->crtLabel,
80 format_CStr("%s%s", 84 format_CStr("%s%s",
81 uiTextAction_ColorEscape, 85 uiTextAction_ColorEscape,
@@ -83,19 +87,19 @@ static iBool tryImport_CertImportWidget_(iCertImportWidget *d, const iBlock *dat
83 setFrameColor_Widget(as_Widget(d->crtLabel), uiTextAction_ColorId); 87 setFrameColor_Widget(as_Widget(d->crtLabel), uiTextAction_ColorId);
84 } 88 }
85 else { 89 else {
86 setTextCStr_LabelWidget(d->crtLabel, uiTextCaution_ColorEscape "${dlg.certimport.nocert}"); 90 updateTextCStr_LabelWidget(d->crtLabel, uiTextCaution_ColorEscape "${dlg.certimport.nocert}");
87 setFrameColor_Widget(as_Widget(d->crtLabel), uiTextCaution_ColorId); 91 setFrameColor_Widget(as_Widget(d->crtLabel), uiTextCaution_ColorId);
88 } 92 }
89 if (d->cert && hasPrivateKey_TlsCertificate(d->cert)) { 93 if (d->cert && hasPrivateKey_TlsCertificate(d->cert)) {
90 iString *fng = collect_String( 94 iString *fng = collect_String(
91 hexEncode_Block(collect_Block(privateKeyFingerprint_TlsCertificate(d->cert)))); 95 hexEncode_Block(collect_Block(privateKeyFingerprint_TlsCertificate(d->cert))));
92 insertData_Block(&fng->chars, size_String(fng) / 2, "\n", 1); 96 insertData_Block(&fng->chars, size_String(fng) / 2, "\n", 1);
93 setTextCStr_LabelWidget( 97 updateTextCStr_LabelWidget(
94 d->keyLabel, format_CStr("%s%s", uiTextAction_ColorEscape, cstr_String(fng))); 98 d->keyLabel, format_CStr("%s%s", uiTextAction_ColorEscape, cstr_String(fng)));
95 setFrameColor_Widget(as_Widget(d->keyLabel), uiTextAction_ColorId); 99 setFrameColor_Widget(as_Widget(d->keyLabel), uiTextAction_ColorId);
96 } 100 }
97 else { 101 else {
98 setTextCStr_LabelWidget(d->keyLabel, uiTextCaution_ColorEscape "${dlg.certimport.nokey}"); 102 updateTextCStr_LabelWidget(d->keyLabel, uiTextCaution_ColorEscape "${dlg.certimport.nokey}");
99 setFrameColor_Widget(as_Widget(d->keyLabel), uiTextCaution_ColorId); 103 setFrameColor_Widget(as_Widget(d->keyLabel), uiTextCaution_ColorId);
100 } 104 }
101 } 105 }
@@ -133,6 +137,8 @@ void init_CertImportWidget(iCertImportWidget *d) {
133 d->crtLabel = findChild_Widget(w, "certimport.crt"); 137 d->crtLabel = findChild_Widget(w, "certimport.crt");
134 d->keyLabel = findChild_Widget(w, "certimport.key"); 138 d->keyLabel = findChild_Widget(w, "certimport.key");
135 d->notes = findChild_Widget(w, "certimport.notes"); 139 d->notes = findChild_Widget(w, "certimport.notes");
140 setFont_LabelWidget(d->crtLabel, uiContent_FontId);
141 setFont_LabelWidget(d->keyLabel, uiContent_FontId);
136 setFixedSize_Widget(as_Widget(d->crtLabel), init_I2(-1, gap_UI * 12)); 142 setFixedSize_Widget(as_Widget(d->crtLabel), init_I2(-1, gap_UI * 12));
137 setFixedSize_Widget(as_Widget(d->keyLabel), init_I2(-1, gap_UI * 12)); 143 setFixedSize_Widget(as_Widget(d->keyLabel), init_I2(-1, gap_UI * 12));
138 } 144 }
@@ -213,6 +219,25 @@ static iBool tryImportFromClipboard_CertImportWidget_(iCertImportWidget *d) {
213 return tryImport_CertImportWidget_(d, collect_Block(newCStr_Block(SDL_GetClipboardText()))); 219 return tryImport_CertImportWidget_(d, collect_Block(newCStr_Block(SDL_GetClipboardText())));
214} 220}
215 221
222static iBool tryImportFromFile_CertImportWidget_(iCertImportWidget *d, const iString *path) {
223 iBool success = iFalse;
224 iFile *f = new_File(path);
225 if (open_File(f, readOnly_FileMode | text_FileMode)) {
226 if (tryImport_CertImportWidget_(d, collect_Block(readAll_File(f)))) {
227 success = iTrue;
228 if (isComplete_CertImportWidget_(d)) {
229 setFocus_Widget(as_Widget(d->notes));
230 }
231 }
232 else {
233 makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.dropped}",
234 "${dlg.certimport.notfound}");
235 }
236 }
237 iRelease(f);
238 return success;
239}
240
216static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Event *ev) { 241static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Event *ev) {
217 iWidget *w = as_Widget(d); 242 iWidget *w = as_Widget(d);
218 if (ev->type == SDL_KEYDOWN) { 243 if (ev->type == SDL_KEYDOWN) {
@@ -254,21 +279,22 @@ static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Even
254 } 279 }
255 return iTrue; 280 return iTrue;
256 } 281 }
257 if (ev->type == SDL_DROPFILE) { 282#if defined (iPlatformAppleMobile)
258 const iString *name = collectNewCStr_String(ev->drop.file); 283 if (isCommand_UserEvent(ev, "certimport.pickfile")) {
259 iFile *f = new_File(name); 284 const char *cmd = command_UserEvent(ev);
260 if (open_File(f, readOnly_FileMode | text_FileMode)) { 285 if (hasLabel_Command(cmd, "path")) {
261 if (tryImport_CertImportWidget_(d, collect_Block(readAll_File(f)))) { 286 const iString *path = collect_String(suffix_Command(cmd, "path"));
262 if (isComplete_CertImportWidget_(d)) { 287 tryImportFromFile_CertImportWidget_(d, path);
263 setFocus_Widget(as_Widget(d->notes)); 288 remove(cstr_String(path)); /* it is a temporary copy */
264 }
265 }
266 else {
267 makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.dropped}",
268 "${dlg.certimport.notfound}");
269 }
270 } 289 }
271 iRelease(f); 290 else {
291 pickFile_iOS("certimport.pickfile");
292 }
293 return iTrue;
294 }
295#endif
296 if (ev->type == SDL_DROPFILE) {
297 tryImportFromFile_CertImportWidget_(d, collectNewCStr_String(ev->drop.file));
272 return iTrue; 298 return iTrue;
273 } 299 }
274 return processEvent_Widget(w, ev); 300 return processEvent_Widget(w, ev);
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index c8010fc6..c9c170cd 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -2314,7 +2314,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
2314 }; 2314 };
2315 const iRangei visLines = visibleLineRange_InputWidget_(d); 2315 const iRangei visLines = visibleLineRange_InputWidget_(d);
2316 const int visLineOffsetY = visLineOffsetY_InputWidget_(d); 2316 const int visLineOffsetY = visLineOffsetY_InputWidget_(d);
2317 iRect markerRects[2]; 2317 iRect markerRects[2] = { zero_Rect(), zero_Rect() };
2318 /* If buffered, just draw the buffered copy. */ 2318 /* If buffered, just draw the buffered copy. */
2319 if (d->buffered && !isFocused) { 2319 if (d->buffered && !isFocused) {
2320 /* Most input widgets will use this, since only one is focused at a time. */ 2320 /* Most input widgets will use this, since only one is focused at a time. */
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index ec324d02..c3c5fbe5 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -504,6 +504,14 @@ void setText_LabelWidget(iLabelWidget *d, const iString *text) {
504 } 504 }
505} 505}
506 506
507void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
508 updateTextCStr_LabelWidget(d, text);
509 updateSize_LabelWidget(d);
510 if (isWrapped_LabelWidget(d)) {
511 sizeChanged_LabelWidget_(d);
512 }
513}
514
507void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) { 515void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) {
508 d->flags.alignVisual = alignVisual; 516 d->flags.alignVisual = alignVisual;
509} 517}
@@ -565,13 +573,6 @@ void updateTextAndResizeWidthCStr_LabelWidget(iLabelWidget *d, const char *text)
565 d->widget.rect.size.x = defaultSize_LabelWidget(d).x; 573 d->widget.rect.size.x = defaultSize_LabelWidget(d).x;
566} 574}
567 575
568void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
569 setCStr_String(&d->label, text);
570 set_String(&d->srcLabel, &d->label);
571 replaceVariables_LabelWidget_(d);
572 updateSize_LabelWidget(d);
573}
574
575void setCommand_LabelWidget(iLabelWidget *d, const iString *command) { 576void setCommand_LabelWidget(iLabelWidget *d, const iString *command) {
576 set_String(&d->command, command); 577 set_String(&d->command, command);
577} 578}
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c
index 3f8b78dc..c199990e 100644
--- a/src/ui/uploadwidget.c
+++ b/src/ui/uploadwidget.c
@@ -328,7 +328,7 @@ static void updateFileInfo_UploadWidget_(iUploadWidget *d) {
328 (iMenuItem[]){ "${dlg.message.ok}", 0, 0, "message.ok" }, 1); 328 (iMenuItem[]){ "${dlg.message.ok}", 0, 0, "message.ok" }, 1);
329 clear_String(&d->filePath); 329 clear_String(&d->filePath);
330 d->fileSize = 0; 330 d->fileSize = 0;
331 return iTrue; 331 return;
332 } 332 }
333 d->fileSize = size_FileInfo(info); 333 d->fileSize = size_FileInfo(info);
334#if defined (iPlatformMobile) 334#if defined (iPlatformMobile)