return;
}
- command = "launch_app org.tizen.image-viewer Path ";
+ command = "/usr/bin/webauthn-image-viewer ";
command += contents.path.c_str();
+ command += " &"; // run background
ret = system(command.c_str());
if (ret) {
- std::cout << "launch_app command failed\n"
+ std::cout << "launching webauthn-image-viewer command failed\n"
<< "System() returned: " << ret << std::endl;
contents.succeeded = false;
}
}
+void CloseQR()
+{
+ // Ignore output
+ int ret __attribute__((__unused__));
+ ret = system("/usr/bin/killall /usr/bin/webauthn-image-viewer &> /dev/null");
+}
+
void GenerateAndDisplayQR(const std::string &encoded, struct TestContents &contents)
{
int ret;
return false;
}
+ CloseQR();
+
std::cout << "START: Get Assertion" << std::endl;
auto lock = std::unique_lock{testContents.mutex};
testContents.succeeded = false;
}
+ CloseQR();
+
timeCount = 120;
std::cout << "Waiting UpdateLinkedData CBs for 120 seconds.." << std::endl;
while (((testContents.statusMC == 1 && testContents.updateMCRet != WAUTHN_ERROR_NONE)
ret = true;
}
- if (system("/usr/bin/killall /usr/apps/org.tizen.image-viewer_common/bin/image-viewer")) {
- std::cout << "Cannot close /usr/apps/org.tizen.image-viewer_common/bin/image-viewer"
- << std::endl;
- if(system("/usr/bin/killall /opt/usr/apps/org.tizen.image-viewer_common/bin/image-viewer")) {
- std::cout << "Cannot close /opt/usr/apps/org.tizen.image-viewer_common/bin/image-viewer"
- << std::endl;
- ret = true;
- }
- }
-
return ret;
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#include <Elementary.h>
+#include <appcore-efl.h>
+#include <Efl_Ui.h>
+
+
+typedef struct appdata {
+ const char *qr_path;
+ Evas_Object *win;
+ Evas_Object *bg;
+ Evas_Object *conform;
+ Evas_Object *entry;
+ Evas_Object *basic_content;
+ Evas_Object *button;
+ Evas_Object *qr_image;
+} appdata_s;
+
+static appdata_s appd =
+{
+ .qr_path = 0,
+ .win = 0,
+ .bg = 0,
+ .conform = 0,
+ .entry = 0,
+ .basic_content = 0,
+ .button = 0,
+ .qr_image = 0
+};
+
+static Evas_Object *
+create_panel_basic_content(Evas_Object *parent, appdata_s *ad)
+{
+ Evas_Object *table;
+
+ /* Table */
+ table = elm_table_add(parent);
+ elm_table_padding_set(table, 10, 10);
+
+ // QR Image
+ ad->qr_image = elm_image_add(table);
+ evas_object_size_hint_weight_set(ad->qr_image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ad->qr_image, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ // elm_image_file_set(ad->qr_image, NULL, NULL);
+ elm_image_file_set(ad->qr_image, ad->qr_path, NULL);
+ evas_object_show(ad->qr_image);
+ elm_table_pack(table, ad->qr_image, 0, 0, 1, 1);
+
+ evas_object_show(table);
+
+ return table;
+}
+
+static Evas_Object *
+create_panel(Evas_Object *parent, appdata_s *ad)
+{
+ Evas_Object *panel, *grid;
+
+ /* Panel */
+ panel = elm_panel_add(parent);
+ elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
+ evas_object_show(panel);
+
+ /* Grid */
+ grid = elm_grid_add(panel);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_content_set(panel, grid);
+
+ /* Panel basic content */
+ ad->basic_content = create_panel_basic_content(grid, ad);
+ evas_object_size_hint_weight_set(ad->basic_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ad->basic_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_grid_pack(grid, ad->basic_content, 3, 3, 94, 94);
+
+ return panel;
+}
+
+static Evas_Object *
+create_bg(Evas_Object *parent)
+{
+ Evas_Object *bg;
+
+ if (parent == NULL) return NULL;
+
+ bg = elm_bg_add(parent);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(parent, bg);
+ evas_object_show(bg);
+
+ return bg;
+}
+
+static Evas_Object *
+create_conform(Evas_Object *parent)
+{
+ Evas_Object *conform, *bg;
+
+ if (parent == NULL) return NULL;
+
+ conform = elm_conformant_add(parent);
+ evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(parent, conform);
+
+ bg = elm_bg_add(conform);
+ elm_object_style_set(bg, "indicator/headerbg");
+ elm_object_part_content_set(conform, "elm.swallow.indicator_bg", bg);
+ evas_object_show(bg);
+
+ evas_object_show(conform);
+ return conform;
+}
+
+static void create_base_gui(appdata_s *ad)
+{
+ Evas_Object *grid, *panel;
+
+ ad->win = elm_win_util_standard_add("NAME", "TITLE");
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+
+ ad->bg = create_bg(ad->win);
+ ad->conform = create_conform(ad->win);
+ elm_win_conformant_set(ad->win, EINA_TRUE);
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+ elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
+
+ // /* Grid */
+ grid = elm_grid_add(ad->conform);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_content_set(ad->conform, grid);
+
+ // /* Panel */
+ panel = create_panel(grid, ad);
+ elm_grid_pack(grid, panel, 0, 0, 100, 100);
+
+ /* Show window after base gui is set up */
+ evas_object_show(ad->win);
+}
+
+static int app_create(void *user_data)
+{
+ appdata_s *ad = (appdata_s *) user_data;
+ create_base_gui(ad);
+ return 1; // Success
+}
+
+static int app_terminate(void *user_data)
+{
+ if (!user_data)
+ return 1;
+
+ appdata_s *ad = (appdata_s *) user_data;
+
+ if (ad->win)
+ evas_object_del(ad->win);
+
+ return 1; // Success
+}
+
+
+static struct appcore_ops ops =
+{
+ .data = &appd,
+ .create = app_create,
+ .terminate = app_terminate,
+ .pause = NULL,
+ .resume = NULL,
+ .reset = NULL,
+ .reserved = {NULL},
+};
+
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ printf("Usage: webauthn-image-viewer QR_PATH\n");
+ return -1;
+ }
+
+ appd.qr_path = argv[1];
+ return appcore_efl_main("Image Viewer", &argc, (char ***)&argv, &ops);
+}