(jabber) Localization, init catkeys

This commit is contained in:
Jaidyn Ann 2021-07-18 22:25:38 -05:00
parent 6875c3cb75
commit 3516c64ffc
3 changed files with 283 additions and 184 deletions

View File

@ -10,6 +10,7 @@
#include <iostream> #include <iostream>
#include <Catalog.h>
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
@ -30,6 +31,10 @@
#include "JabberHandler.h" #include "JabberHandler.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler"
static status_t static status_t
connect_thread(void* data) connect_thread(void* data)
{ {
@ -411,8 +416,8 @@ JabberHandler::UpdateSettings(BMessage* msg)
fClient->registerMessageSessionHandler(this); fClient->registerMessageSessionHandler(this);
fClient->registerMUCInvitationHandler(new InviteHandler(fClient, this)); fClient->registerMUCInvitationHandler(new InviteHandler(fClient, this));
fClient->rosterManager()->registerRosterListener(this); fClient->rosterManager()->registerRosterListener(this);
fClient->disco()->setVersion("Caya", VERSION); fClient->disco()->setVersion("Cardie", VERSION);
fClient->disco()->setIdentity("client", "caya"); fClient->disco()->setIdentity("client", "cardie");
fClient->logInstance().registerLogHandler(gloox::LogLevelDebug, fClient->logInstance().registerLogHandler(gloox::LogLevelDebug,
gloox::LogAreaAll, this); gloox::LogAreaAll, this);
@ -455,129 +460,164 @@ JabberHandler::Client() const
void void
JabberHandler::HandleConnectionError(gloox::ConnectionError& e) JabberHandler::HandleConnectionError(gloox::ConnectionError& e)
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Connection errors"
// Handle error // Handle error
BMessage errMsg(IM_ERROR); BMessage errMsg(IM_ERROR);
switch (e) { switch (e) {
case gloox::ConnStreamError: case gloox::ConnStreamError:
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Connection stream errors"
gloox::StreamError streamError = fClient->streamError(); gloox::StreamError streamError = fClient->streamError();
errMsg.AddString("error", "Bad or malformed XML stream."); errMsg.AddString("error", B_TRANSLATE("Bad or malformed XML stream."));
switch (streamError) { switch (streamError) {
case gloox::StreamErrorBadFormat: case gloox::StreamErrorBadFormat:
errMsg.AddString("detail", "The entity has sent XML that " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"cannot be processed"); "sent XML that cannot be processed"));
break; break;
case gloox::StreamErrorBadNamespacePrefix: case gloox::StreamErrorBadNamespacePrefix:
errMsg.AddString("detail", "The entity has sent a namespace " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"prefix which is not supported, or has sent no namespace " "sent a namespace prefix which is not supported, "
"prefix on an element that requires such prefix."); "or has sent no namespace prefix on an element "
"that requires such prefix."));
break; break;
case gloox::StreamErrorConflict: case gloox::StreamErrorConflict:
errMsg.AddString("detail", "The server is closing the active " errMsg.AddString("detail", B_TRANSLATE("The server is "
"stream for this entity because a new stream has been " "closing the active stream for this entity "
"initiated that conflicts with the existing stream."); "because a new stream has been initiated that "
"conflicts with the existing stream."));
break; break;
case gloox::StreamErrorConnectionTimeout: case gloox::StreamErrorConnectionTimeout:
errMsg.AddString("detail", "The entity has not generated any " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"traffic over the stream for some period of time."); "not generated any traffic over the stream for "
"some period of time."));
break; break;
case gloox::StreamErrorHostGone: case gloox::StreamErrorHostGone:
errMsg.AddString("detail", "The host initially used corresponds " errMsg.AddString("detail", B_TRANSLATE("The host initially "
"to a hostname that is no longer hosted by the server."); "used corresponds to a hostname that is no longer "
"hosted by the server."));
break; break;
case gloox::StreamErrorHostUnknown: case gloox::StreamErrorHostUnknown:
errMsg.AddString("detail", "The host initially used does not " errMsg.AddString("detail", B_TRANSLATE("The host initially "
"correspond to a hostname that is hosted by the server."); "used does not correspond to a hostname that is "
"hosted by the server."));
break; break;
case gloox::StreamErrorImproperAddressing: case gloox::StreamErrorImproperAddressing:
errMsg.AddString("detail", "A stanza sent between two servers " errMsg.AddString("detail", B_TRANSLATE("A stanza sent "
"lacks a 'to' or 'from' attribute (or the attribute has no " "between two servers lacks a 'to' or 'from' "
"value."); "attribute (or the attribute has no value."));
break; break;
case gloox::StreamErrorInternalServerError: case gloox::StreamErrorInternalServerError:
errMsg.AddString("detail", "The Server has experienced a " errMsg.AddString("detail", B_TRANSLATE("The server has "
"misconfiguration or an otherwise-undefined internal error " "experienced a misconfiguration or an "
"that prevents it from servicing the stream."); "otherwise-undefined internal error that prevents "
"it from servicing the stream."));
break; break;
case gloox::StreamErrorInvalidFrom: case gloox::StreamErrorInvalidFrom:
errMsg.AddString("detail", "The JID or hostname provided in a " errMsg.AddString("detail", B_TRANSLATE("The JID or "
"'from' address does not match an authorized JID or validated " "hostname provided in a 'from' address does not "
"domain negotiation between servers via SASL or dialback, or " "match an authorized JID or validated domain "
"between a client and a server via authentication and resource " "negotiation between servers via SASL or dialback, "
"binding."); "or between a client and a server via "
"authentication and resource binding."));
break; break;
case gloox::StreamErrorInvalidId: case gloox::StreamErrorInvalidId:
errMsg.AddString("detail", "The stream ID or dialback ID is invalid " errMsg.AddString("detail", B_TRANSLATE("The stream ID or "
"or does not match and ID previously provdided."); "dialback ID is invalid or does not match and ID "
"previously provdided."));
break; break;
case gloox::StreamErrorInvalidNamespace: case gloox::StreamErrorInvalidNamespace:
errMsg.AddString("detail", "The streams namespace name is something " errMsg.AddString("detail", B_TRANSLATE("The streams "
"other than \"http://etherx.jabber.org/streams\" or the dialback " "namespace name is something other than "
"namespace name is something other than \"jabber:server:dialback\"."); "\"http://etherx.jabber.org/streams\" or the "
"dialback namespace name is something other than "
"\"jabber:server:dialback\"."));
break; break;
case gloox::StreamErrorInvalidXml: case gloox::StreamErrorInvalidXml:
errMsg.AddString("detail", "The entity has sent invalid XML over the " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"stream to a server that performs validation."); "sent invalid XML over the stream to a server that "
"performs validation."));
break; break;
case gloox::StreamErrorNotAuthorized: case gloox::StreamErrorNotAuthorized:
errMsg.AddString("detail", "The entity has attempted to send data before " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"the stream has been authenticated, or otherwise is not authorized to " "attempted to send data before the stream has been "
"perform an action related to stream negotiation; the receiving entity " "authenticated, or otherwise is not authorized to "
"must not process the offending stanza before sending the stream error."); "perform an action related to stream negotiation; "
"the receiving entity must not process the "
"offending stanza before sending the stream "
"error."));
break; break;
case gloox::StreamErrorPolicyViolation: case gloox::StreamErrorPolicyViolation:
errMsg.AddString("detail", "The entity has violated some local service " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"policy; the server may choose to specify the policy in the <text/> " "violated some local service policy; the server "
"element or an application-specific condition element."); "may choose to specify the policy in the <text/> "
"element or an application-specific condition "
"element."));
break; break;
case gloox::StreamErrorRemoteConnectionFailed: case gloox::StreamErrorRemoteConnectionFailed:
errMsg.AddString("detail", "The server is unable to properly connect to " errMsg.AddString("detail", B_TRANSLATE("The server is "
"a remote entit that is required for authentication."); "unable to properly connect to a remote entity "
"that is required for authentication."));
break; break;
case gloox::StreamErrorResourceConstraint: case gloox::StreamErrorResourceConstraint:
errMsg.AddString("detail", "The server lacks the system resources necessary " errMsg.AddString("detail", B_TRANSLATE("The server lacks "
"to service the stream."); "the system resources necessary to service the "
"stream."));
break; break;
case gloox::StreamErrorRestrictedXml: case gloox::StreamErrorRestrictedXml:
errMsg.AddString("detail", "The entity has attempted to send restricted XML " errMsg.AddString("detail", B_TRANSLATE("The entity has "
"features such as a comment, processing instruction, DTD, entity reference " "attempted to send restricted XML features such as "
"or unescaped character."); "a comment, processing instruction, DTD, entity "
"reference or unescaped character."));
break; break;
case gloox::StreamErrorSeeOtherHost: case gloox::StreamErrorSeeOtherHost:
errMsg.AddString("detail", "The server will not provide service to the initiating " errMsg.AddString("detail", B_TRANSLATE("The server will "
"entity but is redirecting traffic to another host; the server should specify " "not provide service to the initiating entity but "
"the alternate hostname or IP address (which MUST be a valid domain identifier) " "is redirecting traffic to another host; the "
"as the XML characted data of the <see-other-host/> element."); "server should specify the alternate hostname or "
"IP address (which MUST be a valid domain "
"identifier) as the XML characted data of the "
"<see-other-host/> element."));
break; break;
case gloox::StreamErrorSystemShutdown: case gloox::StreamErrorSystemShutdown:
errMsg.AddString("detail", "The server is being shut down and all active streams " errMsg.AddString("detail", B_TRANSLATE("The server is "
"are being closed."); "being shut down and all active streams are being "
"closed."));
break; break;
case gloox::StreamErrorUndefinedCondition: case gloox::StreamErrorUndefinedCondition:
errMsg.AddString("detail", "The error condition is not one of those defined by the " errMsg.AddString("detail", B_TRANSLATE("The error "
"other condition in this list; this error condition should be used only in " "condition is not one of those defined by the "
"conjunction with an application-specific condition."); "other condition in this list; this error "
"condition should be used only in conjunction with "
"an application-specific condition."));
break; break;
case gloox::StreamErrorUnsupportedEncoding: case gloox::StreamErrorUnsupportedEncoding:
errMsg.AddString("detail", "The initiating entity has encoded the stream in an " errMsg.AddString("detail", B_TRANSLATE("The initiating "
"encoding that is not supported by the server."); "entity has encoded the stream in an encoding "
"that is not supported by the server."));
break; break;
case gloox::StreamErrorUnsupportedStanzaType: case gloox::StreamErrorUnsupportedStanzaType:
errMsg.AddString("detail", "The initiating entity has sent a first-level child " errMsg.AddString("detail", B_TRANSLATE("The initiating "
"of the stream that is not supported by the server."); "entity has sent a first-level child of the stream "
"that is not supported by the server."));
break; break;
case gloox::StreamErrorUnsupportedVersion: case gloox::StreamErrorUnsupportedVersion:
errMsg.AddString("detail", "The value of the 'version' attribute provided by the " errMsg.AddString("detail", B_TRANSLATE("The value of the "
"initiating entity in the stream header specifies a version of XMPP that is not " "'version' attribute provided by the initiating "
"supported by the server; the server may specify the version(s) it supports in " "entity in the stream header specifies a version "
"the <text/> element."); "of XMPP that is not supported by the server; the "
"server may specify the version(s) it supports in "
"the <text/> element."));
break; break;
case gloox::StreamErrorXmlNotWellFormed: case gloox::StreamErrorXmlNotWellFormed:
errMsg.AddString("detail", "The initiating entity has sent XML that is not " errMsg.AddString("detail", B_TRANSLATE("The initiating "
"well-formed as defined by XML."); "entity has sent XML that is not well-formed as "
"defined by XML."));
break; break;
default: default:
break; break;
@ -585,110 +625,134 @@ JabberHandler::HandleConnectionError(gloox::ConnectionError& e)
break; break;
} }
case gloox::ConnStreamVersionError: case gloox::ConnStreamVersionError:
errMsg.AddString("detail", "The incoming stream's version is not " errMsg.AddString("detail", B_TRANSLATE("The incoming stream's "
"supported."); "version is not supported."));
break; break;
case gloox::ConnStreamClosed: case gloox::ConnStreamClosed:
errMsg.AddString("detail", "The stream has been closed by the server."); errMsg.AddString("detail", B_TRANSLATE("The stream has been closed "
"by the server."));
break; break;
case gloox::ConnProxyAuthRequired: case gloox::ConnProxyAuthRequired:
errMsg.AddString("detail", "The HTTP/SOCKS5 proxy requires authentication."); errMsg.AddString("detail", B_TRANSLATE("The HTTP/SOCKS5 proxy "
"requires authentication."));
break; break;
case gloox::ConnProxyAuthFailed: case gloox::ConnProxyAuthFailed:
errMsg.AddString("detail", "HTTP/SOCKS5 proxy authentication failed."); errMsg.AddString("detail", B_TRANSLATE("HTTP/SOCKS5 proxy "
"authentication failed."));
break; break;
case gloox::ConnProxyNoSupportedAuth: case gloox::ConnProxyNoSupportedAuth:
errMsg.AddString("detail", "The HTTP/SOCKS5 proxy requires an unsupported " errMsg.AddString("detail", B_TRANSLATE("The HTTP/SOCKS5 proxy "
"authentication mechanism."); "requires an unsupported authentication mechanism."));
break; break;
case gloox::ConnIoError: case gloox::ConnIoError:
errMsg.AddString("detail", "Input/output error."); errMsg.AddString("detail", B_TRANSLATE("Input/output error."));
break; break;
case gloox::ConnParseError: case gloox::ConnParseError:
errMsg.AddString("detail", "A XML parse error occurred."); errMsg.AddString("detail", B_TRANSLATE("A XML parse error "
"occurred."));
break; break;
case gloox::ConnConnectionRefused: case gloox::ConnConnectionRefused:
errMsg.AddString("detail", "The connection was refused by the server " errMsg.AddString("detail", B_TRANSLATE("The connection was refused "
"on the socket level."); "by the server on the socket level."));
break; break;
case gloox::ConnDnsError: case gloox::ConnDnsError:
errMsg.AddString("detail", "Server's hostname resolution failed."); errMsg.AddString("detail", B_TRANSLATE("Server's hostname "
"resolution failed."));
break; break;
case gloox::ConnOutOfMemory: case gloox::ConnOutOfMemory:
errMsg.AddString("detail", "Out of memory."); errMsg.AddString("detail", B_TRANSLATE("Out of memory."));
break; break;
case gloox::ConnTlsFailed: case gloox::ConnTlsFailed:
errMsg.AddString("detail", "The server's certificate could not be verified or " errMsg.AddString("detail", B_TRANSLATE("The server's certificate "
"the TLS handshake did not complete successfully."); "could not be verified or the TLS handshake did not "
"complete successfully."));
break; break;
case gloox::ConnTlsNotAvailable: case gloox::ConnTlsNotAvailable:
errMsg.AddString("detail", "The server didn't offer TLS while it was set to be " errMsg.AddString("detail", B_TRANSLATE("The server didn't offer "
"required, or TLS was not compiled in."); "TLS while it was set to be required, or TLS was not "
"compiled in."));
break; break;
case gloox::ConnCompressionFailed: case gloox::ConnCompressionFailed:
errMsg.AddString("detail", "Negotiating or initializing compression failed."); errMsg.AddString("detail", B_TRANSLATE("Negotiating or "
"initializing compression failed."));
break; break;
case gloox::ConnAuthenticationFailed: case gloox::ConnAuthenticationFailed:
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Connection authentication errors"
gloox::AuthenticationError authError = fClient->authError(); gloox::AuthenticationError authError = fClient->authError();
errMsg.AddString("error", "Authentication failed. Username or password wrong " errMsg.AddString("error", B_TRANSLATE("Authentication failed. "
"or account does not exist."); "Username or password wrong or account does not "
"exist."));
switch (authError) { switch (authError) {
case gloox::SaslAborted: case gloox::SaslAborted:
errMsg.AddString("detail", "The receiving entity acknowledges an <abort/> " errMsg.AddString("detail", B_TRANSLATE("The receiving "
"element sent by initiating entity; sent in reply to the <abort/> " "entity acknowledges an <abort/> element sent by "
"element."); "initiating entity; sent in reply to the <abort/> "
"element."));
break; break;
case gloox::SaslIncorrectEncoding: case gloox::SaslIncorrectEncoding:
errMsg.AddString("detail", "The data provided by the initiating entity " errMsg.AddString("detail", B_TRANSLATE("The data provided "
"could not be processed because the base64 encoding is incorrect."); "by the initiating entity could not be processed "
"because the base64 encoding is incorrect."));
break; break;
case gloox::SaslInvalidAuthzid: case gloox::SaslInvalidAuthzid:
errMsg.AddString("detail", "The authid provided by the initiating entity " errMsg.AddString("detail", B_TRANSLATE("The authid "
"is invalid, either because it is incorrectly formatted or because " "provided by the initiating entity is invalid, "
"the initiating entity does not have permissions to authorize that ID; " "either because it is incorrectly formatted or "
"sent in reply to a <response/> element or an <auth/> element with " "because the initiating entity does not have "
"initial response data."); "permissions to authorize that ID; sent in reply "
"to a <response/> element or an <auth/> element "
"with initial response data."));
break; break;
case gloox::SaslInvalidMechanism: case gloox::SaslInvalidMechanism:
errMsg.AddString("detail", "The initiating element did not provide a " errMsg.AddString("detail", B_TRANSLATE("The initiating "
"mechanism or requested a mechanism that is not supported by the " "element did not provide a mechanism or requested "
"receiving entity; sent in reply to an <auth/> element."); "a mechanism that is not supported by the "
"receiving entity; sent in reply to an <auth/> "
"element."));
break; break;
case gloox::SaslMalformedRequest: case gloox::SaslMalformedRequest:
errMsg.AddString("detail", "The request is malformed (e.g., the <auth/> " errMsg.AddString("detail", B_TRANSLATE("The request is "
"element includes an initial response but the mechanism does not " "malformed (e.g., the <auth/> element includes an "
"allow that); sent in reply to an <abort/>, <auth/>, <challenge/>, or " "initial response but the mechanism does not "
"<response/> element."); "allow that); sent in reply to an <abort/>, "
"<auth/>, <challenge/>, or <response/> element."));
break; break;
case gloox::SaslMechanismTooWeak: case gloox::SaslMechanismTooWeak:
errMsg.AddString("detail", "The mechanism requested by the initiating entity " errMsg.AddString("detail", B_TRANSLATE("The mechanism "
"is weaker than server policy permits for that initiating entity; sent in " "requested by the initiating entity is weaker "
"reply to a <response/> element or an <auth/> element with initial " "than server policy permits for that initiating "
"response data."); "entity; sent in reply to a <response/> element or "
"an <auth/> element with initial response data."));
break; break;
case gloox::SaslNotAuthorized: case gloox::SaslNotAuthorized:
errMsg.AddString("detail", "The authentication failed because the initiating " errMsg.AddString("detail", B_TRANSLATE("The authentication "
"entity did not provide valid credentials (this includes but is not " "failed because the initiating entity did not "
"limited to the case of an unknown username); sent in reply to a " "provide valid credentials (this includes but is "
"<response/> element or an <auth/> element with initial response data."); "not limited to the case of an unknown username); "
"sent in reply to a <response/> element or an "
"<auth/> element with initial response data."));
break; break;
case gloox::SaslTemporaryAuthFailure: case gloox::SaslTemporaryAuthFailure:
errMsg.AddString("detail", "The authentication failed because of a temporary " errMsg.AddString("detail", B_TRANSLATE("The authentication "
"error condition within the receiving entity; sent in reply to an " "failed because of a temporary error condition "
"<auth/> element or <response/> element."); "within the receiving entity; sent in reply to an "
"<auth/> element or <response/> element."));
break; break;
case gloox::NonSaslConflict: case gloox::NonSaslConflict:
errMsg.AddString("detail", "Resource conflict, see XEP-0078."); errMsg.AddString("detail", B_TRANSLATE("Resource conflict, "
"see XEP-0078."));
break; break;
case gloox::NonSaslNotAcceptable: case gloox::NonSaslNotAcceptable:
errMsg.AddString("detail", "Required information not provided, " errMsg.AddString("detail", B_TRANSLATE("Required "
"see XEP-0078."); "information not provided, see XEP-0078."));
break; break;
case gloox::NonSaslNotAuthorized: case gloox::NonSaslNotAuthorized:
errMsg.AddString("detail", "Incorrect credentials."); errMsg.AddString("detail", B_TRANSLATE("Incorrect "
"credentials."));
break; break;
default: default:
break; break;
@ -712,85 +776,97 @@ JabberHandler::HandleConnectionError(gloox::ConnectionError& e)
void void
JabberHandler::HandleStanzaError(gloox::StanzaError error) JabberHandler::HandleStanzaError(gloox::StanzaError error)
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Stanza errors"
BMessage errMsg(IM_ERROR); BMessage errMsg(IM_ERROR);
errMsg.AddString("error", "Stanza-related error"); errMsg.AddString("error", B_TRANSLATE("Stanza-related error"));
BString detail; BString detail;
switch (error) switch (error)
{ {
case gloox::StanzaErrorBadRequest: case gloox::StanzaErrorBadRequest:
detail = "The sender has sent XML that is malformed or that cannot " detail = B_TRANSLATE("The sender has sent XML that is malformed or "
"be processed."; "that cannot be processed.");
break; break;
case gloox::StanzaErrorConflict: case gloox::StanzaErrorConflict:
detail = "Access cannot be granted because an existing resource or " detail = B_TRANSLATE("Access cannot be granted because an existing "
"session exists with the same name or address."; "resource or session exists with the same name or address.");
break; break;
case gloox::StanzaErrorFeatureNotImplemented: case gloox::StanzaErrorFeatureNotImplemented:
detail = "This feature hasn't been implemented by the recipient or " detail = B_TRANSLATE("This feature hasn't been implemented by the "
"by the server."; "recipient or by the server.");
break; break;
case gloox::StanzaErrorForbidden: case gloox::StanzaErrorForbidden:
detail = "You don't have permssion to do this."; detail = B_TRANSLATE("You don't have permssion to do this.");
break; break;
case gloox::StanzaErrorGone: case gloox::StanzaErrorGone:
detail = "The recipient or server can no longer be contacted at " detail = B_TRANSLATE("The recipient or server can no longer be "
"this address. Try again later, or with a different address."; "contacted at this address. Try again later, or with a "
"different address.");
break; break;
case gloox::StanzaErrorInternalServerError: case gloox::StanzaErrorInternalServerError:
detail = "The server could not process the stanza because of a " detail = B_TRANSLATE("The server could not process the stanza "
"misconfiguration or an otherwise-undefined internal server error."; "because of a misconfiguration or an otherwise-undefined "
"internal server error.");
break; break;
case gloox::StanzaErrorItemNotFound: case gloox::StanzaErrorItemNotFound:
detail = "The addressed JID or item requested cannot be found."; detail = B_TRANSLATE("The addressed JID or item requested cannot "
"be found.");
break; break;
case gloox::StanzaErrorJidMalformed: case gloox::StanzaErrorJidMalformed:
detail = "An invalid XMPP address or identifier was given. If you " detail = B_TRANSLATE("An invalid XMPP address or identifier was "
"can, please try a different one."; "given. If you can, please try a different one.");
break; break;
case gloox::StanzaErrorNotAcceptable: case gloox::StanzaErrorNotAcceptable:
detail = "The server or user refuses to accept this, because some " detail = B_TRANSLATE("The server or user refuses to accept this, "
"criteria hasn't been met (e.g., a local policy regarding " "because some criteria hasn't been met (e.g., a local policy "
"acceptable words in messages)."; "regarding acceptable words in messages).");
break; break;
case gloox::StanzaErrorNotAllowed: case gloox::StanzaErrorNotAllowed:
detail = "You aren't allowed to do this by the server or recepient."; detail = B_TRANSLATE("You aren't allowed to do this by the server "
"or recepient.");
break; break;
case gloox::StanzaErrorNotAuthorized: case gloox::StanzaErrorNotAuthorized:
detail = "You need to be properily authenticated before doing this."; detail = B_TRANSLATE("You need to be properily authenticated "
"before doing this.");
case gloox::StanzaErrorNotModified: case gloox::StanzaErrorNotModified:
detail = "The item requested has not changed since it was last " detail = B_TRANSLATE("The item requested has not changed since it "
"requested."; "was last requested.");
case gloox::StanzaErrorPaymentRequired: case gloox::StanzaErrorPaymentRequired:
detail = "The server refuses to offer service, because payment is " detail = B_TRANSLATE("The server refuses to offer service, because "
"required."; "payment is required.");
break; break;
case gloox::StanzaErrorRecipientUnavailable: case gloox::StanzaErrorRecipientUnavailable:
detail = "The recipient is temporarily unavailable."; detail = B_TRANSLATE("The recipient is temporarily unavailable.");
break; break;
case gloox::StanzaErrorRedirect: case gloox::StanzaErrorRedirect:
detail = "The recipient or server is redirecting requests for this " detail = B_TRANSLATE("The recipient or server is redirecting "
"information to another entity, usually temporarily."; "requests for this information to another entity, usually "
"temporarily.");
break; break;
case gloox::StanzaErrorRegistrationRequired: case gloox::StanzaErrorRegistrationRequired:
detail = "You can't do this before registration! Be sure your " detail = B_TRANSLATE("You can't do this before registration! Be "
"finished registering for your account."; "sure your finished registering for your account.");
break; break;
case gloox::StanzaErrorRemoteServerNotFound: case gloox::StanzaErrorRemoteServerNotFound:
detail = "That user's server doesn't exist."; detail = B_TRANSLATE("That user's server doesn't exist.");
break; break;
case gloox::StanzaErrorRemoteServerTimeout: case gloox::StanzaErrorRemoteServerTimeout:
detail = "Connection to that user's server has timed out."; detail = B_TRANSLATE("Connection to that user's server has timed "
"out.");
break; break;
case gloox::StanzaErrorResourceConstraint: case gloox::StanzaErrorResourceConstraint:
detail = "The server or recipient are too busy right now; try " detail = B_TRANSLATE("The server or recipient are too busy right "
"again later."; "now; try again later.");
break; break;
case gloox::StanzaErrorServiceUnavailable: case gloox::StanzaErrorServiceUnavailable:
detail = "The server or recipient don't provide this service."; detail = B_TRANSLATE("The server or recipient don't provide this "
"service.");
break; break;
case gloox::StanzaErrorSubscribtionRequired: case gloox::StanzaErrorSubscribtionRequired:
detail = "You can't access this unless you are subscribed."; detail = B_TRANSLATE("You can't access this unless you are "
"subscribed.");
break; break;
} }
@ -1025,7 +1101,7 @@ JabberHandler::_CacheAvatar(const char* id, const char* binimage, size_t length)
file.Write(binimage, length); file.Write(binimage, length);
} }
// Do we need to notify Caya? // Do we need to notify the app?
bool found = false; bool found = false;
BString* item = NULL; BString* item = NULL;
for (int32 i = 0; (item = (BString*)fAvatars->ItemAt(i)); i++) { for (int32 i = 0; (item = (BString*)fAvatars->ItemAt(i)); i++) {
@ -1166,18 +1242,21 @@ JabberHandler::_MUCModeration(BMessage* msg)
const char* const char*
JabberHandler::_RoleTitle(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff) JabberHandler::_RoleTitle(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff)
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― User roles"
switch (role) switch (role)
{ {
case gloox::RoleVisitor: case gloox::RoleVisitor:
return "Visitor"; return B_TRANSLATE("Visitor");
case gloox::RoleParticipant: case gloox::RoleParticipant:
return "Member"; return B_TRANSLATE("Member");
case gloox::RoleModerator: case gloox::RoleModerator:
if (aff == gloox::AffiliationOwner) if (aff == gloox::AffiliationOwner)
return "Owner"; return B_TRANSLATE("Owner");
return "Moderator"; return B_TRANSLATE("Moderator");
} }
return "Invalid"; return B_TRANSLATE("Invalid");
} }
@ -1221,41 +1300,47 @@ JabberHandler::_RolePriority(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation
BMessage BMessage
JabberHandler::_SettingsTemplate(const char* username, bool serverOption) JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Settings template"
BMessage stemplate('IMst'); BMessage stemplate('IMst');
BMessage usernameText; BMessage usernameText;
usernameText.AddString("name", "username"); usernameText.AddString("name", "username");
usernameText.AddString("description", username); usernameText.AddString("description", username);
usernameText.AddString("error", "You can't log into an account without a " usernameText.AddString("error", B_TRANSLATE("You can't log into an account "
"username.\nPlease fill in your username for the given server."); "without a username.\nPlease fill in your username for the given "
"server."));
usernameText.AddInt32("type", 'CSTR'); usernameText.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &usernameText); stemplate.AddMessage("setting", &usernameText);
BMessage passwordText; BMessage passwordText;
passwordText.AddString("name", "password"); passwordText.AddString("name", "password");
passwordText.AddString("description", "Password:"); passwordText.AddString("description", B_TRANSLATE("Password:"));
passwordText.AddString("error", "You can't log into an account without a " passwordText.AddString("error", B_TRANSLATE("You can't log into an account "
"password.\nPlease fill in your password for the given account."); "without a password.\nPlease fill in your password for the given "
"account."));
passwordText.AddInt32("type", 'CSTR'); passwordText.AddInt32("type", 'CSTR');
passwordText.AddBool("is_secret", true); passwordText.AddBool("is_secret", true);
stemplate.AddMessage("setting", &passwordText); stemplate.AddMessage("setting", &passwordText);
BMessage serverText; BMessage serverText;
serverText.AddString("name", "server"); serverText.AddString("name", "server");
serverText.AddString("description", "Server:"); serverText.AddString("description", B_TRANSLATE("Server:"));
serverText.AddString("error", "You can't add an account without a server.\n" serverText.AddString("error", B_TRANSLATE("You can't add an account "
"Please add a valid XMPP server."); "without a server.\nPlease add a valid XMPP server."));
serverText.AddInt32("type", 'CSTR'); serverText.AddInt32("type", 'CSTR');
if (serverOption == true) if (serverOption == true)
stemplate.AddMessage("setting", &serverText); stemplate.AddMessage("setting", &serverText);
BMessage resourceText; BMessage resourceText;
resourceText.AddString("name", "resource"); resourceText.AddString("name", "resource");
resourceText.AddString("description", "Resource:"); resourceText.AddString("description", B_TRANSLATE("Resource:"));
resourceText.AddInt32("type", 'CSTR'); resourceText.AddInt32("type", 'CSTR');
resourceText.AddString("default", "Caya"); resourceText.AddString("default", "Cardie");
resourceText.AddString("error", "You can't add an account without a " resourceText.AddString("error", B_TRANSLATE("You can't add an account "
"resource.\nDon't worry― it can be whatever string you want."); "without a resource.\nDon't worry― it can be whatever string you "
"want."));
stemplate.AddMessage("setting", &resourceText); stemplate.AddMessage("setting", &resourceText);
return stemplate; return stemplate;
@ -1265,12 +1350,15 @@ JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
BMessage BMessage
JabberHandler::_RoomTemplate() JabberHandler::_RoomTemplate()
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Room template"
BMessage stemplate('IMst'); BMessage stemplate('IMst');
BMessage roomIdentifier; BMessage roomIdentifier;
roomIdentifier.AddString("name", "chat_id"); roomIdentifier.AddString("name", "chat_id");
roomIdentifier.AddString("description", "Room ID:"); roomIdentifier.AddString("description", B_TRANSLATE("Room ID:"));
roomIdentifier.AddString("error", "You can't have a room without a JID!\n" roomIdentifier.AddString("error", B_TRANSLATE("You can't have a room "
"Use the \"name@server\" format."); "without a JID!\nUse the \"name@server\" format."));
roomIdentifier.AddInt32("type", 'CSTR'); roomIdentifier.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &roomIdentifier); stemplate.AddMessage("setting", &roomIdentifier);
@ -1281,19 +1369,22 @@ JabberHandler::_RoomTemplate()
BMessage BMessage
JabberHandler::_RosterTemplate() JabberHandler::_RosterTemplate()
{ {
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberHandler ― Roster template"
BMessage stemplate('IMst'); BMessage stemplate('IMst');
BMessage user_id; BMessage user_id;
user_id.AddString("name", "user_id"); user_id.AddString("name", "user_id");
user_id.AddString("description", "User ID:"); user_id.AddString("description", B_TRANSLATE("User ID:"));
user_id.AddString("error", "You can't befriend an IDless miscreant!\n" user_id.AddString("error", B_TRANSLATE("You can't befriend an IDless "
"Please use the \"name@server\" format."); "miscreant!\nPlease use the \"name@server\" format."));
user_id.AddInt32("type", 'CSTR'); user_id.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &user_id); stemplate.AddMessage("setting", &user_id);
BMessage user_name; BMessage user_name;
user_name.AddString("name", "user_name"); user_name.AddString("name", "user_name");
user_name.AddString("description", "Nickname:"); user_name.AddString("description", B_TRANSLATE("Nickname:"));
user_name.AddInt32("type", 'CSTR'); user_name.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &user_name); stemplate.AddMessage("setting", &user_name);

View File

@ -8,11 +8,16 @@
#include "JabberProtocol.h" #include "JabberProtocol.h"
#include <Catalog.h>
#include <Resources.h> #include <Resources.h>
#include <libinterface/BitmapUtils.h> #include <libinterface/BitmapUtils.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "JabberProtocol"
JabberProtocol::JabberProtocol() JabberProtocol::JabberProtocol()
: JabberHandler() : JabberHandler()
{ {
@ -49,7 +54,8 @@ BMessage
JabberProtocol::SettingsTemplate(const char* name) JabberProtocol::SettingsTemplate(const char* name)
{ {
if (strcmp(name, "account") == 0) if (strcmp(name, "account") == 0)
return JabberHandler::_SettingsTemplate("Jabber identifier:", true); return JabberHandler::_SettingsTemplate(B_TRANSLATE("Jabber identifier:"),
true);
if (strcmp(name, "join_room") == 0 || strcmp(name, "create_room") == 0) if (strcmp(name, "join_room") == 0 || strcmp(name, "create_room") == 0)
return JabberHandler::_RoomTemplate(); return JabberHandler::_RoomTemplate();
if (strcmp(name, "roster") == 0) if (strcmp(name, "roster") == 0)

View File

@ -18,7 +18,7 @@ NAME = protocols/jabber
TYPE = SHARED TYPE = SHARED
# If you plan to use localization, specify the application's MIME signature. # If you plan to use localization, specify the application's MIME signature.
APP_MIME_SIG = APP_MIME_SIG = application/x-vnd.cardie.xmpp
# The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are # The following lines tell Pe and Eddie where the SRCS, RDEFS, and RSRCS are
# so that Pe and Eddie can fill them in for you. # so that Pe and Eddie can fill them in for you.
@ -63,7 +63,7 @@ RSRCS =
# - if your library does not follow the standard library naming scheme, # - if your library does not follow the standard library naming scheme,
# you need to specify the path to the library and it's name. # you need to specify the path to the library and it's name.
# (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a")
LIBS = be crypto network support ssl gloox z $(STDCPPLIBS) LIBS = be crypto gloox localestub network support ssl z $(STDCPPLIBS)
# Specify additional paths to directories following the standard libXXX.so # Specify additional paths to directories following the standard libXXX.so
@ -92,7 +92,7 @@ OPTIMIZE :=
# will recreate only the "locales/en.catkeys" file. Use it as a template # will recreate only the "locales/en.catkeys" file. Use it as a template
# for creating catkeys for other languages. All localization files must be # for creating catkeys for other languages. All localization files must be
# placed in the "locales" subdirectory. # placed in the "locales" subdirectory.
LOCALES = LOCALES = en
# Specify all the preprocessor symbols to be defined. The symbols will not # Specify all the preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any) to # have their values set automatically; you must supply the value (if any) to
@ -138,3 +138,5 @@ include $(DEVEL_DIRECTORY)/etc/makefile-engine
include Makefile.common include Makefile.common
include protocols/Makefile.common include protocols/Makefile.common
CATKEYS_DIR = locales/xmpp