-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split header files #1570
Split header files #1570
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes totally makes sense, thanks!
could we reuse the header from escalus/exml in the future?
I think yes, we could. On the other hand, this would mean, that when we need to add new namespace we would need to first update exml in order to use it in MongooseIM.
One more thing. All jobs on travis failed, this is probably not a random failure :) |
Not at all :) I'm working on it. |
Seems to be ok now :) |
Have moved all errors defined as macros to separate module |
There are some macros that transform errors to binaries. These were often defined in multiple places but imo did not fit in the new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?VERSION
inmongoose.hrl
is not fixed/removed.- Not all
mongoose_acc
leftovers are removed frommongoose.hrl
. jid()
and similar definitions should be moved tojlib.erl
- Whole PR needs rebasing.
apps/ejabberd/include/scram.hrl
Outdated
@@ -0,0 +1,5 @@ | |||
-record(scram, | |||
{storedkey = <<"">>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange indent.
apps/ejabberd/include/session.hrl
Outdated
@@ -0,0 +1,6 @@ | |||
-record(session, {sid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sid
should be in new line.
apps/ejabberd/src/ejabberd_c2s.hrl
Outdated
@@ -1,5 +1,9 @@ | |||
-include_lib("ejabberd/include/mod_privacy.hrl"). | |||
|
|||
%% Used to get ?STREAM_TRAILER instead of making separate header file for it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to put it in jlib.hrl
.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
%% All errors are defined in mongoose_xmpp_errors.erl | ||
%% Previously they were defined in up to three different modules | ||
|
||
-define(INVALID_NS_ERR_TO_BIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used only twice. We may get rid of the macro and replace it with exml:to_binary(mongoose_xmpp_errors:invalid_namespace()))
in the code.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
-define(INVALID_NS_ERR_TO_BIN, | ||
exml:to_binary(mongoose_xmpp_errors:invalid_namespace())). | ||
|
||
-define(HOST_UNKNOWN_ERR_TO_BIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used only once, no need for macro at all.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
-define(CONFLICT_ERR_TO_BIN, | ||
exml:to_binary(mongoose_xmpp_errors:stream_conflict())). | ||
|
||
-define(SOCKET_DEFAULT_RESULT, {error, badarg}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used only in s2s_out
, no need to keep it here.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
-define(INVALID_FROM_ERR_TO_BIN, | ||
exml:to_binary(mongoose_xmpp_errors:invalid_from())). | ||
|
||
-define(CONFLICT_ERR_TO_BIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used only in ejabberd_service
, no need for a macro.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
-define(INVALID_XML_ERR_TO_BIN, | ||
exml:to_binary(mongoose_xmpp_errors:xml_not_well_formed())). | ||
|
||
-define(INVALID_FROM_ERR_TO_BIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used only once in s2s_in
, no need for a macro.
apps/ejabberd/src/ejabberd_s2s.hrl
Outdated
-define(HOST_UNKNOWN_ERR_TO_BIN, | ||
exml:to_binary(mongoose_xmpp_errors:host_unknown())). | ||
|
||
-define(INVALID_XML_ERR_TO_BIN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a special, separate function in mongoose_xmpp_errors
, e.g. xml_not_well_formed_bin()
.
Fixing/ removing ?VERSION from mongoose.hrl and rebase remains. |
Change include directive in modules previously including ejabberd.hrl Move type definitions to corresponding modules Remove ejabberd URI
Change usage of constant to exported function-call Remove usage of sm_session type in ejabberd_sm to session type
Move scram record definition to header file Include scram header file in necessary modules
Uncertain about naming of some functions, especially related to stream errors Local test failures seem unrelated to recent changes
Change all old usages of xmlel() to exml:element(). Change all old usages of iq() to jlib:iq()
Change usages of types to match new location
Change macro usages to function calls to mongoose_xmpp_errors There are still error macro definitions defined in ejabberd_s2s_in/out and service
Move macros defined in multiple modules to new header file ejabberd_s2s.hrl
Minor style adjustments Moved ?STREAM_TRAILER to jlib.hrl
Rebase and move new files to new structure
These types are now defined in jlib.erl
ec7c8c3
to
6853f00
Compare
Minor changes to accomodate new structure
src/jlib.erl
Outdated
-export_type([xmlel/0, xmlstreamstart/0, xmlstreamend/0, xmlstreamel/0, | ||
-type iq() :: #iq{}. | ||
|
||
-type user() :: binary(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes more sense to have all JID-related types defined in jid.erl
.
include/mongoose.hrl
Outdated
}). | ||
|
||
-record(external_component, {domain, handler, node}). | ||
-include("mongoose_logger.hrl"). | ||
|
||
-define(DEPRECATED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mongoose_acc
leftover as well.
include/pubsub.hrl
Outdated
@@ -136,13 +136,13 @@ | |||
id ,% :: mod_pubsub:nodeIdx(), | |||
parents = [] ,% :: [mod_pubsub:nodeId(),...], | |||
type = <<"flat">>,% :: binary(), | |||
owners = [] ,% :: [jlib:ljid(),...], | |||
owners = [] ,% :: [jlib::ljid(),...], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why double :
?
Create jid header file to hold jid record definition
This PR splits some header files into more topic-specific ones: logging macros go to
mongoose_logger.hrl
, XMPP namespaces go tomongoose_ns.hrl
(could we reuse the header from escalus/exml in the future?), some MAM specific records go tomod_mam.hrl
.It also makes a small step towards using only namespaced types throughout the codebase, by moving the definition of
rsm_in()
andrsm_out()
from a header intojlib.erl
and adding the module prefix in places where a global type was used before.The motivation is that files which don't use parts defined in the big, generic header files don't include them anymore, which is nice when we want to reuse them outside the project.