signaling_id_util.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_SIGNALING_SIGNALING_ID_UTIL_H_
  5. #define REMOTING_SIGNALING_SIGNALING_ID_UTIL_H_
  6. #include <string>
  7. namespace remoting {
  8. // Normalizes |id|. If |id| is an FTL ID then the email part will be
  9. // canonicalized. Otherwise it will simply convert case-insensitive parts (node
  10. // and domain) to lower-case.
  11. std::string NormalizeSignalingId(const std::string& id);
  12. // Returns the canonical email for the given email. Note that this only works
  13. // for email address and does not work for full signaling ID.
  14. //
  15. // Canonicalizes by:
  16. // * changing to lowercase
  17. // * removing all dots if this is a gmail.com or googlemail.com domain
  18. // * normalize email domain googlemail.com to gmail.com
  19. std::string GetCanonicalEmail(const std::string& email);
  20. // Splits a signaling ID into a the email and a resource suffix. Either
  21. // |full_id|, |resource|, or both may be null. If |full_id| is already an email
  22. // address, |resource| is set to the empty string. Returns true if |full_id|
  23. // has a resource, false if not.
  24. //
  25. // e.g. "user@domain/resource" -> "user@domain", "resource", true
  26. // "user@domain" -> "user@domain", "", false
  27. bool SplitSignalingIdResource(const std::string& full_id,
  28. std::string* email,
  29. std::string* resource);
  30. } // namespace remoting
  31. #endif // REMOTING_SIGNALING_SIGNALING_ID_UTIL_H_