diff --git a/firmware/layout2.c b/firmware/layout2.c index 4ea17ba10..7eca9f5e5 100644 --- a/firmware/layout2.c +++ b/firmware/layout2.c @@ -19,6 +19,7 @@ #include #include +#include #include "layout2.h" #include "storage.h" @@ -264,11 +265,41 @@ void layoutAddress(const char *address, const char *desc) void layoutSignIdentity(const IdentityType *identity, const char *challenge) { + char row_proto[8 + 8 + 1]; + char row_hostport[64 + 6 + 1]; + char row_user[64 + 8 + 1]; + + if (identity->has_proto && identity->proto[0]) { + strlcpy(row_proto, identity->proto, sizeof(row_proto)); + char *p = row_proto; + while (*p) { *p = toupper((int)*p); p++; } + strlcat(row_proto, " login:", sizeof(row_proto)); + } else { + strlcpy(row_proto, "Login:", sizeof(row_proto)); + } + + if (identity->has_host && identity->host[0]) { + strlcpy(row_hostport, identity->host, sizeof(row_hostport)); + if (identity->has_port && identity->port[0]) { + strlcat(row_hostport, ":", sizeof(row_hostport)); + strlcat(row_hostport, identity->user, sizeof(row_hostport)); + } + } else { + row_hostport[0] = 0; + } + + if (identity->has_user && identity->user[0]) { + strlcpy(row_user, "user: ", sizeof(row_user)); + strlcat(row_user, identity->user, sizeof(row_user)); + } else { + row_user[0] = 0; + } + layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", "Sign in using this identity?", - identity->has_proto ? identity->proto : NULL, - identity->has_user ? identity->user : NULL, - identity->has_host ? identity->host : NULL, + row_proto[0] ? row_proto : NULL, + row_hostport[0] ? row_hostport : NULL, + row_user[0] ? row_user : NULL, challenge, NULL, NULL);