Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ZXWifiResultParser.m 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXResult.h"
  17. #import "ZXWifiResultParser.h"
  18. #import "ZXWifiParsedResult.h"
  19. @implementation ZXWifiResultParser
  20. - (ZXParsedResult *)parse:(ZXResult *)result {
  21. NSString *rawText = [ZXResultParser massagedText:result];
  22. if (![rawText hasPrefix:@"WIFI:"]) {
  23. return nil;
  24. }
  25. NSString *ssid = [[self class] matchSinglePrefixedField:@"S:" rawText:rawText endChar:';' trim:NO];
  26. if (ssid == nil || ssid.length == 0) {
  27. return nil;
  28. }
  29. NSString *pass = [[self class] matchSinglePrefixedField:@"P:" rawText:rawText endChar:';' trim:NO];
  30. NSString *type = [[self class] matchSinglePrefixedField:@"T:" rawText:rawText endChar:';' trim:NO];
  31. if (type == nil) {
  32. type = @"nopass";
  33. }
  34. BOOL hidden = [[[self class] matchSinglePrefixedField:@"H:" rawText:rawText endChar:';' trim:NO] boolValue];
  35. return [ZXWifiParsedResult wifiParsedResultWithNetworkEncryption:type ssid:ssid password:pass hidden:hidden];
  36. }
  37. @end